2013-06-05 63 views
1

我试图复制一个现有的Android项目来开始半新。在我的旧项目中,我能够将自定义主题应用于应用程序。在我的新应用程序中,即使我已经复制了所有style.xml文件,并且更改了清单中的min和target sdk版本,但无法将其构建为最小/目标sdk。它的构建,但我的应用程序仍然有顶部的旧式通知栏,而不是操作栏。我不知道如何强制IntelliJ/Android为新版本构建。android自定义应用程序主题不被应用

我的清单

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

    <uses-permission android:name="android.permission.INTERNET"/> 
    <uses-permission android:name="android.permission.CALL_PHONE"/> 
    <uses-permission android:name="android.permission.CAMERA"/> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 

    <uses-sdk android:minSdkVersion="11" 
       android:targetSdkVersion="16"/> 
    <application 
      android:label="@string/app_name" 
      android:theme="@style/AppTheme" 
      android:icon="@drawable/app_icon" 
      android:name=".injected.C2Application" 
      > 
     <activity android:name=".HomeActivity"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN"/> 
       <category android:name="android.intent.category.LAUNCHER"/> 
      </intent-filter> 
     </activity> 
    </application> 
</manifest> 

我的风格

<?xml version="1.0" encoding="utf-8"?> 
<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:Theme.Light"> 
     <!-- 
      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"> 
     <item name="android:actionBarStyle">@style/LoginActionBarStyle</item> 
     <item name="android:textColorHint">#D1D1D1</item> 
    </style> 

    <style name="LoginActionBarStyle" parent="@android:style/Widget.Holo.ActionBar"> 
     <item name="android:displayOptions">showHome</item> 
     <item name="android:background">#333333</item> 
    </style> 

    <style name="LoginFormContainer"> 
     <item name="android:layout_width">match_parent</item> 
     <item name="android:layout_height">wrap_content</item> 
     <item name="android:padding">16dp</item> 
    </style> 
</resources> 

它看起来像现在

What it looks like now

什么什么就应该想

enter image description here

我不知道什么是/未设置。

+0

哪个样式文件是这样吗?向我们展示您的-v11和-v14。 –

+1

文件是values/styles.xml – David

+0

如果您的目标为11+,那么您的基础样式应该从holo继承而不是轻量级。或者除了这个文件,你还需要一个-v11样式的文件。 –

回答

3

您需要第二个从Holo继承的V11 +样式文件。 查看正确方法来完成此任务的最简单方法就是创建一个新的hello世界项目,并了解他们是如何在该项目中完成的。

另外值得一提的是,使用这种技术的操作栏只会显示在V11 +设备上。 要在所有设备上显示它,您需要使用ActionBarSherlock,但由于您的最小版本设置为11,因此您可能不打算支持2.3手机。

实施例:

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:Theme.Light"> 
    <!-- 
     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> 

值-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.Light"> 
    <!-- API 11 theme customizations can go here. --> 
</style> 

值-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.Light.DarkActionBar"> 
    <!-- API 14 theme customizations can go here. --> 
</style> 

的manifest.xml

<uses-sdk 
    android:minSdkVersion="8" 
    android:targetSdkVersion="17" /> 

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" > 
    <activity 
     android:name="com.example.test.test.com.MainActivity" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

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

+0

我已经有这两个文件。我认为它与没有Android支持库有关 – David

+0

支持库不用于此 –