2012-11-29 121 views
1

我有一个布局在屏幕的底部有五个水平按钮,其中之一是'更多的按钮'。安卓滑动抽屉的按钮

“更多按钮”我想开一个滑动抽屉有三个按钮或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> 

论“imgMore”点击,滑动抽屉应打开3个按钮。

请修改我的布局以适应更改。

我已经试过这....

<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> 

+0

你试过了什么? –

回答

0

this例子可以帮助你。在这个例子中,如果你想添加一个依赖于你的文本,它只会显示一个按钮,不管它是静态的还是动态的。

这只是为了指导你。

+0

这没有达到我的目的....我想要线性对齐的其他按钮也滑动和隐藏,以便只有更多的按钮与抽屉一起可见。 – ParijatDev

+0

没有得到?在图像 –

+0

中显示它与facebook幻灯片抽屉相同,在按钮上单击一个布局并与之前的布局重叠。 请参阅视频... http://www.youtube.com/watch?v=ANLMaL7zn20 – ParijatDev