抽屉的使用-SlidingDrawer--有个抽屉锁拉拽(过时)

布局文件如下:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    
    <Button 
        android:text="我是主布局里的按钮"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
    
  <!-- 移动抽屉 ,必须写下面两个属性
          android:handle  这个作为抽屉的把手
          android:content 这个为抽屉里的内容
          android:orientation 默认为vertical,代表从下网上拉. horizontal代表从右往左拉
          SlidingDrawer里的高度决定着这个抽屉拉出来的高度,把手也就在这个抽屉布局位置的最下面-->
    <SlidingDrawer 
        android:id="@+id/slidingDrawer"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:orientation="horizontal"
        android:layout_alignParentBottom="true"
        android:handle="@+id/my_handle"
        android:content="@+id/my_content">
       <!-- 注意这里的id就为SlidingDrawer里定义的把手id,也是把它作为把手的标志 .这里也可以使用布局作为把手,这样便于控制图片位置,默认为中间位置--> 
        <ImageView 
            android:id="@id/my_handle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"/>
       <!-- 这个布局作为抽屉的内容 --> 
        <LinearLayout 
            android:id="@id/my_content"
            android:background="#ffcccc"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            >
            
            <TextView 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="30sp"
                android:text="我是抽屉里的文字"/>
            
        </LinearLayout>
        
    </SlidingDrawer>

</RelativeLayout>

效果图:

posted @ 2016-09-07 21:13  ts-android  阅读(683)  评论(0编辑  收藏  举报