Android SlidingDrawer 抽屜效果的實(shí)現(xiàn)
SlidingDrawer隱藏屏外的內(nèi)容,并允許用戶通過(guò)handle以顯示隱藏內(nèi)容。它可以垂直或水平滑動(dòng),它有倆個(gè)View組成,其一是可以拖動(dòng)的handle,其二是隱藏內(nèi)容的View.它里面的控件必須設(shè)置布局,在布局文件中必須指定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 <!--隱藏的內(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、下面是運(yùn)行程序之后的界面


另:可在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:指示是否可以通過(guò)handle打開(kāi)或關(guān)閉
android:animateOnClick:指示是否當(dāng)使用者按下手柄打開(kāi)/關(guān)閉時(shí)是否該有一個(gè)動(dòng)畫。
android:content:隱藏的內(nèi)容
android:handle:handle(手柄)
2、重要方法
animateClose():關(guān)閉時(shí)實(shí)現(xiàn)動(dòng)畫。
close():即時(shí)關(guān)閉
getContent():獲取內(nèi)容
isMoving():指示SlidingDrawer是否在移動(dòng)。
isOpened():指示SlidingDrawer是否已全部打開(kāi)
lock():屏蔽觸摸事件。
setOnDrawerCloseListener(SlidingDrawer.OnDrawerCloseListener onDrawerCloseListener):SlidingDrawer關(guān)閉時(shí)調(diào)用
setOnDrawerOpenListener
setOnDrawerScrollListener
unlock():解除屏蔽觸摸事件。
toggle():切換打開(kāi)和關(guān)閉的抽屜SlidingDrawer。
- Android開(kāi)發(fā)之DrawerLayout實(shí)現(xiàn)抽屜效果
- Android編程實(shí)現(xiàn)抽屜效果的方法詳解
- Android 自定義View實(shí)現(xiàn)抽屜效果
- Android自定義控件仿QQ抽屜效果
- Android DrawerLayout實(shí)現(xiàn)抽屜效果實(shí)例代碼
- Android 抽屜效果的導(dǎo)航菜單實(shí)現(xiàn)代碼實(shí)例
- Android實(shí)現(xiàn)自定義滑動(dòng)式抽屜菜單效果
- Android App中DrawerLayout抽屜效果的菜單編寫實(shí)例
- Android的Activity跳轉(zhuǎn)動(dòng)畫各種效果整理
- Android Tween動(dòng)畫之RotateAnimation實(shí)現(xiàn)圖片不停旋轉(zhuǎn)效果實(shí)例介紹
- Android實(shí)現(xiàn)圖片輪播效果的兩種方法
- Android編程實(shí)現(xiàn)抽屜效果的方法示例
相關(guān)文章
Android仿視頻加載旋轉(zhuǎn)小球動(dòng)畫效果的實(shí)例代碼
這篇文章主要介紹了Android仿視頻加載旋轉(zhuǎn)小球動(dòng)畫效果的實(shí)例代碼,文中給大家提到了PathMeasure的用法,介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-09-09
Android自定義控件實(shí)現(xiàn)下拉刷新效果
這篇文章主要為大家詳細(xì)介紹了Android自定義控件實(shí)現(xiàn)下拉刷新效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-08-08
Flutter中如何實(shí)現(xiàn)無(wú)Context跳轉(zhuǎn)詳解
這篇文章主要給大家介紹了關(guān)于Flutter中如何實(shí)現(xiàn)無(wú)Context跳轉(zhuǎn)的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Flutter具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-09-09
Android Studio下載更新Android SDK網(wǎng)絡(luò)異?;驘o(wú)法下載
這篇文章主要介紹了Android Studio下載更新Android SDK網(wǎng)絡(luò)異常或無(wú)法下載的相關(guān)資料,需要的朋友可以參考下2017-04-04
Kotlin中Stack與LinkedList的實(shí)現(xiàn)方法示例
這篇文章主要給大家介紹了關(guān)于Kotlin中Stack與LinkedList實(shí)現(xiàn)的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考借鑒,下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2018-06-06
android RecycleView實(shí)現(xiàn)下拉刷新和上拉加載
這篇文章主要為大家詳細(xì)介紹了android RecycleView實(shí)現(xiàn)下拉刷新和上拉加載,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-06-06
Android點(diǎn)擊EditText文本框之外任何地方隱藏鍵盤的解決辦法
這篇文章主要介紹了Android點(diǎn)擊EditText文本框之外任何地方隱藏鍵盤的解決辦法,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-01-01

