2013-08-04 35 views
2

我是Android新手,好像挂了一下...Android/Eclipse应用主题的麻烦

我正在尝试构建我的第一个Android应用程序。该应用程序大多只是Eclipse为您创建的模板...

我想使用Holo主题的基础和默认的黑色背景。我可以在Manifest中通过硬编码“@android:style/Theme.Holo”来使它工作(在模拟器上)。但是我无法将它从styles.xml中拉出来。

即使我做硬编码在清单中的Eclipse仍显示在活动编辑器,这使得与白色文本在白色背景上很难设计一个白色背景...

我敢肯定,这小东西我错过了。请参考下面...

在此先感谢 彼得

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="ca.domain.test2" 
    android:versionCode="1" 
    android:versionName="1.0" > 

    <uses-sdk 
     android:minSdkVersion="10" 
     android:targetSdkVersion="18" /> 

    <uses-permission android:name="android.permission.VIBRATE" /> 

    <application 
     android:allowBackup="true" 
     android:icon="@drawable/icon48" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 
     <activity 
      android:name="ca.domain.test2.Something" 
      android:configChanges="keyboardHidden|orientation|screenSize" 
      android:label="@string/app_name" 
      android:screenOrientation="portrait" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
    </application> 

</manifest> 

<resources xmlns:android="http://schemas.android.com/apk/res/android"> 

    <!-- 
     Base application theme, dependent on API level. This theme is replaced 
     by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 
    --> 
    <style name="AppBaseTheme" parent="android:Theme.Holo"> 
     <!-- 
      Theme customizations available in newer API levels can go in 
      res/values-vXX/styles.xml, while customizations related to 
      backward-compatibility can go here. 
     --> 
    </style> 

    <!-- Application theme. --> 
    <style name="AppTheme" parent="AppBaseTheme"> 
     <!-- All customizations that are NOT specific to a particular API-level can go here. --> 
    </style> 

</resources> 

回答

5

这是因为你把它放在RES /价值/ styles.xml文件,这意味着它的适用于每个API版本的应用程序,但最多10个版本不支持Holo主题。所以,这是你的文件应该怎么样子:

RES /价值/ styles.xml

<resources> 

<!-- 
    Base application theme, dependent on API level. This theme is replaced 
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 
--> 
<style name="AppBaseTheme" parent="@android:style/Theme.Black"> 
    <!-- 
     Theme customizations available in newer API levels can go in 
     res/values-vXX/styles.xml, while customizations related to 
     backward-compatibility can go here. 
    --> 
</style> 

<!-- Application theme. --> 
<style name="AppTheme" parent="AppBaseTheme"> 
    <!-- All customizations that are NOT specific to a particular 
     API-level can go here. --> 
</style> 

</resources> 

RES /值-V11/styles.xml

<resources> 

<!-- 
    Base application theme for API 11+. This theme completely replaces 
    AppBaseTheme from res/values/styles.xml on API 11+ devices. 
--> 
<style name="AppBaseTheme" parent="android:Theme.Holo"> 
    <!-- API 11 theme customizations can go here. --> 
</style> 

</resources> 

res/values-v14/styles.xml

<resources> 

<!-- 
    Base application theme for API 14+. This theme completely replaces 
    AppBaseTheme from BOTH res/values/styles.xml and 
    res/values-v11/styles.xml on API 14+ devices. 
--> 
<style name="AppBaseTheme" parent="android:Theme.Holo"> 
    <!-- API 14 theme customizations can go here. --> 
</style> 

</resources> 
+0

工作。我知道它在某处被覆盖。我正在考虑遗产的倒退。谢谢。 – PrecisionPete