Android SlidingDrawer 使用方法

发布于 2024-09-29 19:04:25 字数 168 浏览 0 评论 0原文

我已经看过很多地方,但我找不到关于如何为我的应用程序制作 SlidingDrawer 的像样的教程。

假设我已经有一个 XML 文件,并且我想向其中添加一个滑动抽屉...我还想添加一个 textview 和 listview 对象,以及其中的一些按钮...我该怎么做?

任何帮助将不胜感激!

I've looked in many places, but I cant find a decent tutorial on how to make a SlidingDrawer for my application.

Say i already have an XML file, and i want to add a sliding drawer to it..i also want to add a textview and listview object, and some buttons in it...how would i go about doing that?

Any help will be greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

似梦非梦 2024-10-06 19:04:25

这是一个 SlidingDrawer 示例应用。特别是,这是布局:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#FF4444CC"
        >
    <SlidingDrawer
        android:id="@+id/drawer"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:handle="@+id/handle"
        android:content="@+id/content">
        <ImageView
            android:id="@id/handle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/tray_handle_normal"
        />
        <Button
            android:id="@id/content"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:text="I'm in here!"
        />
    </SlidingDrawer>
</FrameLayout>

现在,在本例中,整个活动只是一个 SlidingDrawer。这是相对不寻常的——这个示例很短,因为它来自一本书。

更常见的是,我希望您将 SlidingDrawer 作为 RelativeLayout 的子级,这样您就可以拥有 RelativeLayout 的其他子级并拥有打开时抽屉滑过它们的顶部。我相信在这种情况下,您需要将 SlidingDrawer 作为 RelativeLayout 的最后一个子级。

Here is a SlidingDrawer sample app. In particular, here is the layout:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#FF4444CC"
        >
    <SlidingDrawer
        android:id="@+id/drawer"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:handle="@+id/handle"
        android:content="@+id/content">
        <ImageView
            android:id="@id/handle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/tray_handle_normal"
        />
        <Button
            android:id="@id/content"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:text="I'm in here!"
        />
    </SlidingDrawer>
</FrameLayout>

Now, in this case, the whole activity is just a SlidingDrawer. That's relatively unusual -- this sample is short because it is from a book.

More commonly, I would expect you to put a SlidingDrawer as a child of a RelativeLayout, so you can have other children of the RelativeLayout and have the drawer slide over top of them when opened. I believe you will need the SlidingDrawer to be the last child of the RelativeLayout in this case.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文