现在的位置: 首页 > 综合 > 正文

Android Training精要(二)開啟ActionBar的Overlay模式

2014年08月29日 ⁄ 综合 ⁄ 共 1025字 ⁄ 字号 评论关闭

在3.0上的實現

<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>

還需要在遮蓋的Layout上加上android:paddingTop的值

<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>

2.1上的實現:

<resources> 
    <!-- the theme applied to the application or activity --> 
    <style name="CustomActionBarTheme" 
           parent="@android:style/Theme.AppCompat"> 
        <item name="android:windowActionBarOverlay">true</item> 
        <!-- Support library compatibility --> 
        <item name="windowActionBarOverlay">true</item> 
    </style> 
</resources>

在遮蓋的Layout上加上android:paddingTop的值

<!-- 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>


抱歉!评论已关闭.