Android SlidingDrawer 抽屜效果的實現(xiàn)
SlidingDrawer隱藏屏外的內(nèi)容,并允許用戶通過handle以顯示隱藏內(nèi)容。它可以垂直或水平滑動,它有倆個View組成,其一是可以拖動的handle,其二是隱藏內(nèi)容的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 <!--隱藏的內(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中添加文件
<?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:隱藏的內(nèi)容
android:handle:handle(手柄)
2、重要方法
animateClose():關閉時實現(xiàn)動畫。
close():即時關閉
getContent():獲取內(nèi)容
isMoving():指示SlidingDrawer是否在移動。
isOpened():指示SlidingDrawer是否已全部打開
lock():屏蔽觸摸事件。
setOnDrawerCloseListener(SlidingDrawer.OnDrawerCloseListener onDrawerCloseListener):SlidingDrawer關閉時調(diào)用
setOnDrawerOpenListener
setOnDrawerScrollListener
unlock():解除屏蔽觸摸事件。
toggle():切換打開和關閉的抽屜SlidingDrawer。
- Android開發(fā)之DrawerLayout實現(xiàn)抽屜效果
- Android編程實現(xiàn)抽屜效果的方法詳解
- Android 自定義View實現(xiàn)抽屜效果
- Android自定義控件仿QQ抽屜效果
- Android DrawerLayout實現(xiàn)抽屜效果實例代碼
- Android 抽屜效果的導航菜單實現(xiàn)代碼實例
- Android實現(xiàn)自定義滑動式抽屜菜單效果
- Android App中DrawerLayout抽屜效果的菜單編寫實例
- Android的Activity跳轉動畫各種效果整理
- Android Tween動畫之RotateAnimation實現(xiàn)圖片不停旋轉效果實例介紹
- Android實現(xiàn)圖片輪播效果的兩種方法
- Android編程實現(xiàn)抽屜效果的方法示例
相關文章
android中SwipeRefresh實現(xiàn)各種上拉,下拉刷新示例
這篇文章主要介紹了android中SwipeRefresh實現(xiàn)各種上拉,下拉刷新示例,非常具有實用價值,需要的朋友可以參考下。2017-03-03Android布局之絕對布局AbsoluteLayout詳解
這篇文章主要為大家詳細介紹了Android布局之絕對布局AbsoluteLayout的相關資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-10-10Android 使用SharePerference判斷是否為第一次登陸的實現(xiàn)代碼
很多app中在第一次安裝登陸時會有引導歡迎界面,第二次打開時就不再顯示引導頁面。這個怎么實現(xiàn)呢?下面小編給大家介紹下使用SharePerference判斷是否為第一次登陸的實現(xiàn)代碼,需要的的朋友參考下吧2017-03-03Android2.3實現(xiàn)Android4.0風格EditText的方法
這篇文章主要介紹了Android2.3實現(xiàn)Android4.0風格EditText的方法,涉及Android界面布局及控件調(diào)用的相關技巧,需要的朋友可以參考下2016-03-03ERROR/AndroidRuntime(17121)的問題解決
ERROR/AndroidRuntime(17121)的問題解決,需要的朋友可以參考一下2013-05-05Android canvas畫圖操作之切割畫布實現(xiàn)方法(clipRect)
這篇文章主要介紹了Android canvas畫圖操作之切割畫布實現(xiàn)方法,通過clipRect方法實現(xiàn)canvas畫布的切割操作,需要的朋友可以參考下2016-10-10Android實現(xiàn)RecyclerView嵌套流式布局的詳細過程
最近在做需求的時候,碰到有各種篩選項的界面,下面這篇文章主要給大家介紹了關于Android實現(xiàn)RecyclerView嵌套流式布局的詳細過程,文中通過示例代碼介紹的非常詳細,需要的朋友可以參考下2022-12-12