使用DrawerLayout組件實(shí)現(xiàn)側(cè)滑抽屜的功能
DrawerLayout組件同樣是V4包中的組件,也是直接繼承于ViewGroup類,所以這個類也是一個容器類。使用DrawerLayout可以輕松的實(shí)現(xiàn)抽屜效果,使用DrawerLayout的步驟有以下幾點(diǎn):
1)在DrawerLayout中,第一個子View必須是顯示內(nèi)容的view,并且設(shè)置它的layout_width和layout_height屬性是match_parent.
2)第二個view是抽屜view,并且設(shè)置屬性layout_gravity="left|right",表示是從左邊滑出還是右邊滑出。設(shè)置它的layout_height="match_parent"
例子:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawerlayout" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <TextView android:id="@+id/textview" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:text="content" /> <ListView android:id="@+id/listview" android:layout_width="80dp" android:layout_height="match_parent" android:layout_gravity="left" android:background="#FFB5C5" /> </android.support.v4.widget.DrawerLayout>
實(shí)現(xiàn)的效果:

以上所述是小編給大家介紹的使用DrawerLayout組件實(shí)現(xiàn)側(cè)滑抽屜的功能,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
Android 網(wǎng)絡(luò)圖片查看器與網(wǎng)頁源碼查看器
本篇文章主要介紹了Android 網(wǎng)絡(luò)圖片查看器與網(wǎng)頁源碼查看器的相關(guān)知識。具有很好的參考價值。下面跟著小編一起來看下吧2017-04-04
Android studio實(shí)現(xiàn)PopupWindow彈出框效果
這篇文章主要為大家詳細(xì)介紹了Android studio實(shí)現(xiàn)PopupWindow彈出框效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-10-10
android 仿微信聊天氣泡效果實(shí)現(xiàn)思路
微信聊天窗口的信息效果類似iphone上的短信效果,以氣泡的形式展現(xiàn),實(shí)現(xiàn)這種效果主要用到ListView和BaseAdapter,配合布局以及相關(guān)素材,接下來為大家介紹下如何實(shí)現(xiàn)2013-04-04
ViewPager 滑動一半的判斷方法以及左滑右滑判斷實(shí)例
下面小編就為大家?guī)硪黄猇iewPager 滑動一半的判斷方法以及左滑右滑判斷實(shí)例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-04-04

