a亚洲精品_精品国产91乱码一区二区三区_亚洲精品在线免费观看视频_欧美日韩亚洲国产综合_久久久久久久久久久成人_在线区

首頁 > 系統 > Android > 正文

Android SlidingDrawer 抽屜效果的實現

2020-04-11 12:29:18
字體:
來源:轉載
供稿:網友

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

1、布局layou文件

復制代碼 代碼如下:

<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 <!--隱藏的內容-->
    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中添加文件

復制代碼 代碼如下:

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

總結:

1、重要屬性

  android:allowSingleTap:指示是否可以通過handle打開或關閉

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

  android:content:隱藏的內容

  android:handle:handle(手柄)

2、重要方法

  animateClose():關閉時實現動畫。

  close():即時關閉

  getContent():獲取內容

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

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

  lock():屏蔽觸摸事件。

  setOnDrawerCloseListener(SlidingDrawer.OnDrawerCloseListener onDrawerCloseListener):SlidingDrawer關閉時調用

  setOnDrawerOpenListener

  setOnDrawerScrollListener

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

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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 欧美资源在线 | 999国内精品永久免费视频 | 国产第一亚洲 | 日本一区二区三区视频在线 | 国产视频三区 | www国产亚洲精品久久网站 | 日韩中文一区二区三区 | 羞羞视频免费观看入口 | 亚洲一区二区视频免费观看 | 日本黄色一级片视频 | 高清久久 | 国产福利久久 | 欧美精品一区二区三区四区 | 精品国产一区二区三区日日嗨 | 二区在线视频 | 欧美日韩成人在线播放 | 国产性×xxx盗摄xxxx | 成人激情视频在线观看 | 四虎影院最新网站 | 91福利影院在线观看 | 欧美二区精品 | 国产美女自拍视频 | 亚洲天堂免费 | 精品视频在线免费 | 毛片大全 | 国产精品一区二区三区在线播放 | av在线免费观看网站 | 岛国在线免费 | 自拍偷拍欧美 | 亚洲女人天堂成人av在线 | 久久精品国产一区二区电影 | 福利视频网站 | 岛国一区 | 龙珠z普通话国语版在线观看 | 一区不卡在线 | 久久99精品国产99久久6男男 | 涩999| 草久av| 97成人在线免费视频 | 五月婷婷在线观看视频 | 色视频网站免费看 |