欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android組件之DrawerLayout實(shí)現(xiàn)抽屜菜單

 更新時(shí)間:2016年02月13日 18:05:22   作者:小老鼠開公司  
DrawerLayout組件同樣是V4包中的組件,也是直接繼承于ViewGroup類,所以這個(gè)類也是一個(gè)容器類。接下來通過本文給大家介紹Android組件之DrawerLayout實(shí)現(xiàn)抽屜菜單,感興趣的朋友一起學(xué)習(xí)吧

DrawerLayout組件同樣是V4包中的組件,也是直接繼承于ViewGroup類,所以這個(gè)類也是一個(gè)容器類。

抽屜菜單的擺放和布局通過android:layout_gravity屬性來控制,可選值為left、right或start、end。通過xml來布局的話,需要把DrawerLayout作為父容器,組界面布局作為其第一個(gè)子節(jié)點(diǎn),抽屜布局則緊隨其后作為第二個(gè)子節(jié)點(diǎn),這樣就做就已經(jīng)把內(nèi)容展示區(qū)和抽屜菜單區(qū)獨(dú)立開來,只需要分別為兩個(gè)區(qū)域設(shè)置內(nèi)容即可。android提供了一些實(shí)用的監(jiān)聽器,重載相關(guān)的回調(diào)方法可以在菜單的交互過程中書寫邏輯業(yè)務(wù)。

使用DrawerLayout可以輕松的實(shí)現(xiàn)抽屜效果,使用DrawerLayout的步驟有以下幾點(diǎn):

1)在DrawerLayout中,第一個(gè)子View必須是顯示內(nèi)容的view,并且設(shè)置它的layout_width和layout_height屬性是match_parent.

2)第二個(gè)view是抽屜view,并且設(shè)置屬性layout_gravity="left|right",表示是從左邊滑出還是右邊滑出。設(shè)置它的layout_height="match_parent"

eg:

<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)的效果:


以上所述是小編給大家介紹的Android組件之DrawerLayout實(shí)現(xiàn)抽屜菜單的相關(guān)知識(shí),希望對(duì)大家有所幫助。

相關(guān)文章

最新評(píng)論