【发布时间】:2010-11-12 15:33:43
【问题描述】:
你知道如何实现和winamp for android一样的效果吗?我想做类似的事情。那是当我点击listview时,滑动抽屉弹出。但到目前为止,我只能在不同的新活动中显示滑动抽屉。
如何在重叠视图中实现。也就是当我关闭抽屉时,布局显示在前面,滑动手柄在布局上,当我打开抽屉时,它覆盖了主布局。
对此有什么想法吗?
谢谢!!
【问题讨论】:
标签: android slidingdrawer
你知道如何实现和winamp for android一样的效果吗?我想做类似的事情。那是当我点击listview时,滑动抽屉弹出。但到目前为止,我只能在不同的新活动中显示滑动抽屉。
如何在重叠视图中实现。也就是当我关闭抽屉时,布局显示在前面,滑动手柄在布局上,当我打开抽屉时,它覆盖了主布局。
对此有什么想法吗?
谢谢!!
【问题讨论】:
标签: android slidingdrawer
第 1 步:创建 RelativeLayout
第 2 步:将 UI 的其余部分放入 RelativeLayout
第 3 步:将 SlidingDrawer 作为后面的子元素放在 RelativeLayout 中,然后是 UI 的其余部分(例如,在布局 XML 中,将其作为 RelativeLayout 的最后一个子元素)
RelativeLayout(和FrameLayout)的子代在 Z 轴上(即屏幕外)相互堆叠。因此,较晚的孩子将与较早的孩子重叠。通过将您的SlidingDrawer 放在最后,它会在打开时与其他所有内容重叠。
【讨论】:
谢谢你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>
【讨论】: