2014-06-12 32 views
0

對於我的Android應用程序,我希望我的應用程序在KitKat(API級別19)上具有半透明狀態和導航欄。我該如何做到這一點,因此19級API操作系統具有透明的狀態/導航欄,而非KitKat的則具有普通的條形圖。(Android)特定於API的樣式?

+3

價值觀-V19使用styles.xml定義和值 – njzk2

+0

@ njzk2請問如何已經完成了? –

+0

@ njzk2我能找到的最高值是values-v14 –

回答

2

您需要定義一個自定義主題,並設置這些屬性API級別19

首先,創建一個styles.xml文件res\values

它應具有以下內容:

<?xml version="1.0" encoding="utf-8"?> 
<resources xmlns:android="http://schemas.android.com/apk/res/android"> 
    <style name="MyCustomTheme" parent="@android:style/Theme"> 
    </style> 
</resources> 

parent="@android:style/Theme"可能會根據您想要的基本主題(例如Theme.Light,Theme.Holo,Theme.Holo.Light或其他)而不同。

然後在res\values-v19創建類似styles.xml文件,與此內容:

<?xml version="1.0" encoding="utf-8"?> 
<resources xmlns:android="http://schemas.android.com/apk/res/android"> 
    <style name="MyCustomTheme" parent="@android:style/Theme.Holo"> 
     <item name="android:windowTranslucentStatus">true</item> 
     <item name="android:windowTranslucentNavigation">true</item> 
    </style> 
</resources> 

(同前,親本可以是不同的)。

而在你AndroidManifest.xml文件,查找application節點,並添加/更新的主題屬性,即

<application 
    android:icon= ... 
    android:theme="@style/MyCustomTheme"> 
+0

我看到了兩個值文件夾:一個在app/src/main/res中,另一個在build/exploded-aar/com.android.support/appcompat-v7/19.1中。 0/RES。我使用哪一個? –

+0

總是在'src'中。另一個文件夾是由構建過程創建的,你不應該碰它裏面的任何東西。 – matiash

+0

如何「在AndroidManifest.xml中配置它」?我需要什麼代碼? –