2014-06-12 35 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中配置它”?我需要什么代码? –