目的:
側拉抽屜出來的效果要高度填滿整個螢幕高(同play商店)。
PS.側拉抽屜預設效果會在ActionBar底下滑出
元件:
- android.support.v4.widget.DrawerLayout
- android.support.v7.widget.Toolbar
操作:
- 針對Activity的style 設定<item name="windowActionBar">false</item>
- 針對Activity的style 設定<item name="windowActionModeOverlay">true</item>
- class中設定setSupportActionBar( toolbar ) ;
**但是這樣getSupportActionBar()就會回傳null**
Q1:
只有一個頁面使用側拉抽屜,但其它頁面不需使用,但需仍需要使用ActionBar。
但是Activity的style中不設定<item name="windowActionBar">false</item>又不行。
若不設定的話,在使用setSupportActionBar( toolbar ) 將會發生Exception。
Error message:
java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
A1:
- 另外設定一個style
- 在使用class頁面中的onCreate()的第一行、super.onCreate( savedInstanceState )前,設定額外的style
setTheme( R.style.另外的style ) ; - 其餘照舊
style code:
<style name="HomeTheme" parent="AppBaseTheme">
<item name="windowActionBar">false</item>
<item name="windowActionModeOverlay">true</item>
</style>
reference:
http://stackoverflow.com/a/12724687
沒有留言:
張貼留言