谷歌官方推出了一種側(cè)滑菜單的實現(xiàn)方式(抽屜效果),即 DrawerLayout,這個類是在Support Library里的,需要加上android-support-v4.jar這個包。
成都創(chuàng)新互聯(lián)公司從2013年成立,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目網(wǎng)站制作、做網(wǎng)站網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元旌陽做網(wǎng)站,已為上家服務(wù),為旌陽各地企業(yè)和個人服務(wù),聯(lián)系電話:13518219792使用注意點
1、DrawerLayout的第一個子元素必須是默認(rèn)內(nèi)容,即抽屜沒有打開時顯示的布局(如FrameLayout),后面緊跟的子元素是抽屜內(nèi)容,即抽屜布局(如ListView)。
2、抽屜菜單的擺放和布局通過android:layout_gravity屬性來控制,可選值為left、right或start、end。
3、抽屜菜單的寬度為 dp 單位而高度和父View一樣。抽屜菜單的寬度應(yīng)該不超過320dp,這樣用戶可以在菜單打開的時候看到部分內(nèi)容界面。
4、打開抽屜: DrawerLayout .openDrawer(); 關(guān)閉抽屜:DrawerLayout.closeDrawer( );
一個典型的布局實例:
<android.support.v4.widget.DrawerLayoutxmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="fill_parent" android:layout_height="fill_parent"> <!--可以在程序中根據(jù)抽屜菜單 切換Fragment--> <FrameLayout android:id="@+id/fragment_layout" android:background="#0000ff" android:layout_width="fill_parent" android:layout_height="fill_parent"> </FrameLayout> <!--左邊抽屜菜單--> <RelativeLayout android:id="@+id/menu_layout_left" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="left" android:background="#ff0000"> <ListView android:id="@+id/menu_listView_l" android:layout_width="match_parent" android:layout_height="match_parent"> </ListView> </RelativeLayout> <!--右邊抽屜菜單--> <RelativeLayout android:id="@+id/menu_layout_right" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="right" android:background="#00ff00"> <ListView android:id="@+id/menu_listView_r" android:layout_width="match_parent" android:layout_height="match_parent"> </ListView> </RelativeLayout> </android.support.v4.widget.DrawerLayout>
本文名稱:Android開發(fā)之DrawerLayout實現(xiàn)抽屜效果-創(chuàng)新互聯(lián)
URL標(biāo)題:http://muchs.cn/article48/cdcshp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站排名、網(wǎng)站制作、網(wǎng)站內(nèi)鏈、關(guān)鍵詞優(yōu)化、網(wǎng)頁設(shè)計公司、外貿(mào)網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)