DrawerLayout佈局使用,開啟與關閉,DrawerLayout佔滿全螢幕
阿新 • • 發佈:2021-02-03
從左邊開啟
mDrawerLayout.openDrawer(GravityCompat.START);
從右邊開啟
mDrawerLayoutopenDrawer(GravityCompat.END);
關閉左邊
mDrawerLayout.closeDrawer(GravityCompat.START);
關閉右邊
mDrawerLayout.closeDrawer(GravityCompat.END);
關閉所有側滑頁面
mDrawerLayout.closeDrawers();
DrawerLayout佔滿全螢幕
//xml檔案中設定
android:layout_width="match_parent" //如果要全屏滑出選單需設定寬度為macth_parent
android:layout_marginRight="-65dp" // 設定-65dp,佔滿剩餘無法滑動到的65dp