滑动抽屉采用相同的布局

时间:2010-11-12 15:33:44

标签: android slidingdrawer

你知道如何实现与winamp相同的Android效果吗?我想做类似的事情。那是我点击listview,滑动抽屉弹出窗口。但到目前为止,我只能在不同的新活动中显示滑动抽屉。

如何在重叠视图中实现。那是当我关闭抽屉时,布局显示在前面,滑动手柄在布局上,当我打开抽屉时,它覆盖了主要布局。

有关于此的任何想法吗?

谢谢!

2 个答案:

答案 0 :(得分:11)

步骤1:创建RelativeLayout

步骤2:将您的其余用户界面放在RelativeLayout

步骤#3:将SlidingDrawer作为后一个孩子放在RelativeLayout中,然后将UI的其余部分放置(例如,在布局XML中,将其作为{{1的最后一个子元素) }})

RelativeLayout(和RelativeLayout)的孩子在Z轴上堆叠在一起(即,在屏幕的外面)。因此,后来的孩子会与之前的孩子重叠。通过将FrameLayout放在最后,它会在打开时与其他所有内容重叠。

答案 1 :(得分:0)

谢谢你 CommonsWare 你帮了我,我没有太多的声誉可以投票了。这是我的样本布局......

我使用it.sephiroth.slider.widget.MultiDirectionSlidingDrawer作为SlidingDrawer

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="match_parent">
<RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:layout_alignParentLeft="true" android:layout_marginLeft="82dp"
        android:layout_alignTop="@+id/button_open">

    <Button
            android:id="@+id/button_open"
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:text="@string/open"
            android:visibility="visible" />
    <EditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="New EditText"
            android:id="@+id/editText" android:layout_alignParentLeft="true" android:layout_marginLeft="114dp"
            android:layout_alignParentTop="true" android:layout_marginTop="6dp"/>
</RelativeLayout>

<it.sephiroth.demo.slider.widget.MultiDirectionSlidingDrawer
        xmlns:panel="http://schemas.android.com/apk/res/it.sephiroth.demo.slider"
        android:id="@+id/drawer"

        panel:direction="topToBottom"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        panel:handle="@+id/handle"
        panel:content="@+id/content">
    <include
            android:id="@id/content"
            layout="@layout/pen_content" />
    <ImageView
            android:id="@id/handle"
            android:layout_width="wrap_content"
            android:layout_height="40px"
            android:src="@drawable/sliding_drawer_handle_bottom" />
</it.sephiroth.demo.slider.widget.MultiDirectionSlidingDrawer>
</RelativeLayout>