Reputation: 10738
I'm trying to copy over an existing Android project to start semi-new. In my old project i was able to apply a custom theme to the application. In my new application, even though i have copied over all of the style.xml files and changed the min and target sdk versions in the manifest i can't get it to build for it's minimum/target sdk. It builds but my application still has the old style notification bar at the top, not the Action bar. I have no idea how to force IntelliJ/Android to build for the new version.
my manifest
<?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>
my style
<?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
What it should like
I have no idea what is/isn't being set.
Upvotes: 1
Views: 6084
Reputation: 10886
You need a second style file for V11+ that inherits from Holo. The easiest way to see the right way to do this is just make a new hello world project and see how they did it in there.
Also worth mentioning using this technique the actionbar will only be shown on V11+ devices. To show it on all devices you would need to use ActionBarSherlock, but since you have your min version set to 11 maybe you don't plan on supporting 2.3 phones.
Example:
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>
values-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>
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.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>
Upvotes: 3