ActionBarはOverlay Modeをオンにします(オーバーライドモード)
5758 ワード
以下の内容はAndroid公式サイトよりhttp://developer.android.com/training/basics/actionbar/overlaying.html#EnableOverlay
ActionBarのhide()メソッドとshow()メソッドを直接呼び出すと、Activityがレイアウトの新しいサイズを再計算して再描画します.このようなことを避けるためには、Overlay Modeを使用する必要があります.
3.0以上で、上書きモードを有効にするには、android:windowActionBarOverlayプロパティをカスタムThemeでtrueに設定するだけです.例:
3.0以下の場合:
マニフェストに行くのを忘れないでxmlファイルはThemeを設定します.
上書きモードでActionBarの下にレイアウトを表示する場合は、レイアウトファイルの親レイアウトでpaddingTopプロパティ値を設定します.
3.0以降:
3.0次のバージョン:
ヒント:ActionBarをレイアウトの前に表示させる場合は、ActionBarの背景を透明に設定することもできます.
効果は以下の通りです.
ActionBarのhide()メソッドとshow()メソッドを直接呼び出すと、Activityがレイアウトの新しいサイズを再計算して再描画します.このようなことを避けるためには、Overlay Modeを使用する必要があります.
3.0以上で、上書きモードを有効にするには、android:windowActionBarOverlayプロパティをカスタムThemeでtrueに設定するだけです.例:
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme" parent="@android:style/Theme.Holo">
<item name="android:windowActionBarOverlay">true</item>
</style>
</resources>
3.0以下の場合:
<resources> <!-- the theme applied to the application or activity --> <style name="CustomActionBarTheme" parent="@android:style/Theme.AppCompat"> <!-- Support library compatibility --> <item name="windowActionBarOverlay">true</item> </style>
</resources>
マニフェストに行くのを忘れないでxmlファイルはThemeを設定します.
上書きモードでActionBarの下にレイアウトを表示する場合は、レイアウトファイルの親レイアウトでpaddingTopプロパティ値を設定します.
3.0以降:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingTop="?android:attr/actionBarSize"> ... </RelativeLayout>
3.0次のバージョン:
<!-- Support library compatibility -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingTop="?attr/actionBarSize"> ... </RelativeLayout>
ヒント:ActionBarをレイアウトの前に表示させる場合は、ActionBarの背景を透明に設定することもできます.
効果は以下の通りです.