Sliding drawer in the same layout

故事扮演 提交于 2019-12-04 19:05:40

Step #1: Create a RelativeLayout

Step #2: Put the rest of your UI in the RelativeLayout

Step #3: Put the SlidingDrawer in the RelativeLayout as a later child then the rest of the UI (e.g., in layout XML, have it as the last child element of the RelativeLayout)

Children of RelativeLayout (and FrameLayout) stack on top of one another on the Z-axis (i.e., out the face of the screen). Hence, later children will overlap earlier ones. By putting your SlidingDrawer last, it will overlap everything else when opened.

Thank you CommonsWare you helped me,I do not have much reputation to vote up. Here is my sample layout...

I used it.sephiroth.slider.widget.MultiDirectionSlidingDrawer as the 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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!