关于SlidingDrawer控件介绍

来源:互联网 发布:vb视频大学生自学网 编辑:程序博客网 时间:2024/06/08 01:54

一、效果(写给自己理解)



必须指定handle(手柄)和content(内容)的控件的id,下面的孩子再用是直接用id不用谢+号了。

布局比较简单,

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >


    <TextView
        android:layout_width="fill_parent"
        android:layout_height="50dip"
        android:background="#8866ff00"
        android:gravity="center"
        android:text="流量统计"
        android:textSize="22sp" />


    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="horizontal" >


        <View
            android:layout_width="200dip"
            android:layout_height="fill_parent" >
        </View>


        <SlidingDrawer
           
            android:id="@+id/slidingdrawer01"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:content="@+id/mycontent"
            android:handle="@+id/myhandle"

            android:orientation="horizontal" >


            <LinearLayout
                 android:id="@id/myhandle"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent" >


                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/lock" />
            </LinearLayout>


            <LinearLayout
                android:id="@id/mycontent"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#22000000"
                android:gravity="center"
                android:orientation="vertical" >


                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="我是抽屉里面的文本" />
            </LinearLayout>
        </SlidingDrawer>
    </LinearLayout>
</LinearLayout>

二、重要属性

  android:allowSingleTap:指示是否可以通过handle打开或关闭

  android:animateOnClick:指示是否当使用者按下手柄打开/关闭时是否该有一个动画。

  android:content:隐藏的内容

  android:handle:handle(手柄)

三、重要方法

  animateClose():关闭时实现动画。

  close():即时关闭

  getContent():获取内容

  isMoving():指示SlidingDrawer是否在移动。

  isOpened():指示SlidingDrawer是否已全部打开

  lock():屏蔽触摸事件。

  setOnDrawerCloseListener(SlidingDrawer.OnDrawerCloseListener onDrawerCloseListener):SlidingDrawer关闭时调用

  unlock():解除屏蔽触摸事件。

  toggle():切换打开和关闭的抽屉SlidingDrawer。

0 0
原创粉丝点击