2

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

假设我已经有一个 XML 文件,并且我想向它添加一个滑动抽屉。我还想添加一个 textview 和 listview 对象,以及其中的一些按钮...我将如何去做呢?

任何帮助将不胜感激!

4

1 回答 1

3

这是一个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. 这是相对不寻常的——这个样本很短,因为它来自一本书。

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

于 2010-11-01T20:05:33.700 回答