国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > Android > 正文

Android SlidingDrawer 抽屜效果的實現(xiàn)

2020-04-11 12:29:18
字體:
供稿:網(wǎng)友

SlidingDrawer隱藏屏外的內(nèi)容,并允許用戶通過handle以顯示隱藏內(nèi)容。它可以垂直或水平滑動,它有倆個View組成,其一是可以拖動的handle,其二是隱藏內(nèi)容的View.它里面的控件必須設(shè)置布局,在布局文件中必須指定handle和content。

1、布局layou文件

復(fù)制代碼 代碼如下:

<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="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<SlidingDrawer
  android:id="@+id/slidingdrawer"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:content="@+id/content"
  android:handle="@+id/handle"
  android:orientation="vertical" >
  <Button
    android:id="@+id/handle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="SlidingDraser" />
  <LinearLayout <!--隱藏的內(nèi)容-->
    android:id="@+id/content"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#00ffaa" >
    <Button
      android:id="@+id/button"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Button" />
    <EditText
      android:id="@+id/editText"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content" />
  </LinearLayout>
</SlidingDrawer>
</LinearLayout>


 2、下面是運行程序之后的界面

另:可在drawable中添加文件

復(fù)制代碼 代碼如下:

    <?xml version="1.0" encoding="utf-8"?> 
    <selector xmlns:android="http://schemas.android.com/apk/res/android"> 
        <item android:state_window_focused="false" android:state_enabled="true" android:drawable="@drawable/handle_normal" /> 
        <item android:state_pressed="true" android:drawable="@drawable/handle_pressed" /> 
        <item android:state_focused="true" android:state_enabled="true" android:drawable="@drawable/handle_focused" /> 
        <item android:state_enabled="true" android:drawable="@drawable/handle_normal" /> 
        <item android:state_focused="true" android:drawable="@drawable/handle_focused" /> 
    </selector> 

總結(jié):

1、重要屬性

  android:allowSingleTap:指示是否可以通過handle打開或關(guān)閉

  android:animateOnClick:指示是否當(dāng)使用者按下手柄打開/關(guān)閉時是否該有一個動畫。

  android:content:隱藏的內(nèi)容

  android:handle:handle(手柄)

2、重要方法

  animateClose():關(guān)閉時實現(xiàn)動畫。

  close():即時關(guān)閉

  getContent():獲取內(nèi)容

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

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

  lock():屏蔽觸摸事件。

  setOnDrawerCloseListener(SlidingDrawer.OnDrawerCloseListener onDrawerCloseListener):SlidingDrawer關(guān)閉時調(diào)用

  setOnDrawerOpenListener

  setOnDrawerScrollListener

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

  toggle():切換打開和關(guān)閉的抽屜SlidingDrawer。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 扶沟县| 贺兰县| 西乡县| 日喀则市| 石景山区| 息烽县| 福建省| 大冶市| 南溪县| 沂水县| 武川县| 临清市| 丹江口市| 德保县| 长岛县| 汉寿县| 新巴尔虎左旗| 清新县| 县级市| 镇宁| 水富县| 渝北区| 新竹县| 天等县| 孟津县| 天峻县| 凯里市| 陈巴尔虎旗| 南木林县| 建阳市| 新宁县| 绵竹市| 安化县| 图们市| 浙江省| 宣化县| 湖北省| 江北区| 铜川市| 平凉市| 镶黄旗|