简体   繁体   English

Android滑动抽屉的按钮

[英]Android sliding Drawer for a button

I have a layout in the bottom of the screen which has five horizontal buttons, one of them is the 'more button'. 我在屏幕底部有一个布局,其中有五个水平按钮,其中一个是“更多按钮”。

On the click of the 'more button' I want to open a sliding drawer with three buttons or textviews: 在单击“更多按钮”时,我想打开一个带有三个按钮或文本视图的滑动抽屉:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/global_bg" >

<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true" >

    <ImageView
        android:id="@+id/imageView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/navicon_search" />

    <ImageView
        android:id="@+id/imageView9"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/nav_divider" />

    <ImageView
        android:id="@+id/imageView5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/nav_icon_video" />

    <ImageView
        android:id="@+id/imageView9"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/nav_divider" />

    <ImageView
        android:id="@+id/imageView6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/nav_icon_news" />

    <ImageView
        android:id="@+id/imageView9"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/nav_divider" />

    <ImageView
        android:id="@+id/imageView7"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/nav_icon_ecommerce" />

    <ImageView
        android:id="@+id/imageView9"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/nav_divider" />

    <ImageView
        android:id="@+id/imgMore"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/nav_icon_more" />
</LinearLayout>

<ImageView
    android:id="@+id/ImageView01"
    android:layout_width="match_parent"
    android:layout_height="10dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:background="@null"
    android:scaleType="fitXY"
    android:src="@drawable/top_color_bar" />

<RelativeLayout
    android:id="@+id/relativeLayout1"
    android:layout_width="wrap_content"
    android:layout_height="80dp"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/ImageView01"
    android:background="@drawable/global_masthead" >

    <ImageView
        android:id="@+id/imgbtnBackFromResetAddTime"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:src="@drawable/topnav_backarrow_small" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="Add Time"
        android:textSize="20dp"
        android:textStyle="bold" />

    <ImageView
        android:id="@+id/imgListOpen"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@+id/imageView1"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:src="@drawable/topnav_geomap_small" />
</RelativeLayout>

On click of 'imgMore', a sliding drawer should open with 3 buttons. 在单击“ imgMore”时,应打开一个带有3个按钮的滑动抽屉。

Please modify my layout to accomodate the changes. 请修改我的布局以适应更改。

I have tried this.... 我已经尝试过了...

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/global_bg" >

<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true" >

    <ImageView
        android:id="@+id/imageView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/navicon_search" />

    <ImageView
        android:id="@+id/imageView9"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/nav_divider" />

    <ImageView
        android:id="@+id/imageView5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/nav_icon_video" />

    <ImageView
        android:id="@+id/imageView9"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/nav_divider" />

    <ImageView
        android:id="@+id/imageView6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/nav_icon_news" />

    <ImageView
        android:id="@+id/imageView9"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/nav_divider" />

    <ImageView
        android:id="@+id/imageView7"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/nav_icon_ecommerce" />

    <ImageView
        android:id="@+id/imageView9"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/nav_divider" />

    <SlidingDrawer
        android:id="@+id/SlidingDrawer"
        android:layout_width="wrap_content"
        android:layout_height="250dip"
        android:content="@+id/contentLayout"
        android:handle="@+id/imgMore"
        android:orientation="horizontal"
        android:padding="10dip" >

        <ImageView
            android:id="@+id/imgMore"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:src="@drawable/nav_icon_more" />

        <LinearLayout
            android:id="@+id/contentLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#cccccc"
            android:gravity="center"
            android:orientation="vertical"
            android:padding="10dip" >

            <Button
                android:id="@+id/Button01"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_margin="2dp"
                android:text="Option1" >
            </Button>

            <Button
                android:id="@+id/Button02"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_margin="2dp"
                android:text="Option2" >
            </Button>

            <Button
                android:id="@+id/Button03"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_margin="2dp"
                android:text="Option3" >
            </Button>

            <Button>
            </Button>
        </LinearLayout>
    </SlidingDrawer>
</LinearLayout>

<ImageView
    android:id="@+id/ImageView01"
    android:layout_width="match_parent"
    android:layout_height="10dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:background="@null"
    android:scaleType="fitXY"
    android:src="@drawable/top_color_bar" />

<RelativeLayout
    android:id="@+id/relativeLayout1"
    android:layout_width="wrap_content"
    android:layout_height="80dp"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/ImageView01"
    android:background="@drawable/global_masthead" >

    <ImageView
        android:id="@+id/imgbtnBackFromResetAddTime"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:src="@drawable/topnav_backarrow_small" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="Add Time"
        android:textSize="20dp"
        android:textStyle="bold" />

    <ImageView
        android:id="@+id/imgListOpen"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@+id/imageView1"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:src="@drawable/topnav_geomap_small" />
</RelativeLayout>

See this example will help you. 查看示例将对您有所帮助。 in this example that is only show you a button if you want to add text that is depen on you either it will be static or dynamic. 在此示例中,仅在您要添加依赖于您的文本的按钮上显示该按钮,该按钮是静态的还是动态的。

This is only for guide you. 这仅用于指导您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM