2014-02-13 31 views
3

在Android的奇巧有用於QuickPic如何做一個半透明的操作欄?

<item name="android:actionBarStyle">@style/TranslucentActionBar</item> 
    <item name="android:windowActionBarOverlay">true</item> 
    <item name="android:windowTranslucentStatus">true</item> 
    <item name="android:windowTranslucentNavigation">true</item> 

選項如何有一個應用程序,其中在滾動內容開始滾動操作欄下方喜歡下載快執行?

<FrameLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/container" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
android:clipToPadding="false" 
tools:context="com.jhdev.red.MainActivity" 
tools:ignore="MergeRootFrame" > 

<GridView 
    android:id="@+id/grid" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:numColumns="@integer/num_columns" 
    android:clipToPadding="false"/> 

</FrameLayout> 
+0

嗨朱利安,你是否得到了解決?我也在尋找同樣的東西。 –

回答

2

對於Android的3.0和更高版本

如果您的minSdkVersion設置爲11或更高版本,您的自定義主題應該使用Theme.Holo主題(或它的後代之一)作爲父主題。例如:

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

對於Android 2.1及更高

如果您的應用使用支持庫的兼容性上運行的版本低於Android 3.0的,你的自定義主題應該使用Theme.AppCompat主題設備(或其後代之一)作爲您的父主題。例如:

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

指定佈局頂邊距

當動作欄爲覆蓋模式,它可能會掩蓋一些你的佈局應保持可見。要確保這些項目始終保持在操作欄下方,請使用actionBarSize指定的高度將視野邊緣或邊距添加到視圖頂部。例如:

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

如果您使用操作欄的支持庫,則需要刪除android:前綴。例如:?

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

在這種情況下,ATTR /不帶前綴actionBarSize值適用於所有版本,包括Android 3.0及更高版本。

Details

還檢查了這link更多的幫助。

1

您需要使用:

android:clipChildren="false" 

您的FrameLayout

0

只需設置操作欄的樣式在你的應用程序的主題是這樣的:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 

    ... 

    <item name="android:actionBarStyle">@style/TransparentActionBar</item> 
    <item name="android:windowActionBarOverlay">true</item> 
    <!-- Support library compatibility --> 
    <item name="actionBarStyle">@style/TransparentActionBar</item> 
    <item name="windowActionBarOverlay">true</item> 
</style> 

<!--Default alpha for translucent navigation/status bar is 40% of black color--> 
<color name="transparent_color">#6000</color> 

<style name="TransparentActionBar" parent="Widget.AppCompat.ActionBar.Solid"> 
    <item name="android:background">@color/transparent_color</item> 
    <!--Compatibility--> 
    <item name="background">@color/transparent_color</item> 
</style>