Holo Theme and API 8 - android

I have an app that must be supported from API 8+. But I also like to have my app the holo theme for(11+). I know it won't be supported as the min sdk is 8. So the only solution will be to create 2 separate apps one for 8-11 and one for 11+. Is there any better way to do this? So that I can reduce double maintenance.

There's no need to create two separate apps. You just need to create two definitions of theme for your app:
styles.xml in /res/values-v11 (Will be used only on API 11+)
<resources>
<style name="app_theme" parent="android:Theme.Holo.Light"/>
</resources>
styles.xml in /res/values
<resources>
<style name="app_theme" parent="android:Theme.Light"/>
</resources>
and then, apply it to your application in AndroidManifest.xml:
<application
...
android:theme="#style/app_theme"
>
...
</application>
This setup uses resource qualifiers. You can read more about them here.

You can try the HoloEverywhere library to use Holo theme on Android 2.1+. It also integrates well with ActionBarSherlock.

Related

Dialog Theme.DeviceDefault forced

I am making a dialog, where I want to show EditTexts and Radio buttons.
But the theme is not applying. According to Layout Inspector, the Views have the correct theme applied (shown "forced"), but there is "android:style/Theme.DeviceDefault()", which is also "forced" (it is shown above my style, if that matters).
The problem is, that the Views look differently on different APIs, which I guess is caused by that DeviceDefault. I have not set anywhere anything about DeviceDefault, but it applies to all my Dialogs.
Any idea how to dissmiss it? Thanks.
Every API level has its own default theme and since you use the default theme to your app, android adjusts the theme depending on the API level which will be different on each device. Just remember that just the element of which you add the style attribute to gets the specified style attributes. The child objects or child view does not get the style attribute. If you want child views to inherit styles, instead apply the style with the android:theme attribute.
The problem is probolby linked to where, and how, you apply your own theme.
You should apply your theme in the AndroidManifest.xml file. If you apply your theme in the application tag or the activity tag, you cover different parts of the application with your theme. What you have done is hard to say without any code present.
You should apply your theme to one of the following sections of the file.
To cover the whole application
<manifest ... >
<application android:theme="#style/Theme.AppCompat" ... >
</application>
</manifest>
To cover just one activity
<manifest ... >
<application ... >
<activity android:theme="#style/Theme.AppCompat.Light" ... >
</activity>
</application>
</manifest>
If a view supports only some of the attributes that you declared in the style that you created, it then only applies those attributes and ignores the ones it does not support.
If you want to change the default style and colors, you can override them in the styles.xml file. Search for the item name that represents the color value and change corresponding value in the res/values/colors.xml file.
I hope this information will solv your problem, but as I said, it this really hard so exactly say without the code present.
About Theme.DeviceDefaul in Android:
There are many Themes available for Android devices.
Theme: the default for the earliest versions of Android up to 2.3 Gingerbread(10)
Theme.Holo: from Android 3.0 Honeycomb (11)
Theme.Material: from Android 5.0 Lollipop (21)
Theme.DeviceDefault: from Android 4.0 Ice Cream Sandwich (14), a theme that can be customized by the device manufacturer. It represents the native look of the device.
Specifying different themes:
Android's resource overlay system allows to specify styles based on device API level, via Android Studio will setup for you.
For example different versions of a style in res/values-v11 and res/values-v21.
/res/values/styles.xml is applied to every device and serves as base:
<resources>
<style name="AppTheme" parent="android:Theme.Light"/>
</resources>
/res/values-v11/styles.xml is loaded on all devices that have API level 11 and above (including those that are 21 and above):
<resources>
<style name="AppTheme" parent="android:Theme.Holo.Light"/>
</resources>
/res/values-v21/styles.xml is loaded on all devices that have API level 21 and above:
<resources>
<style name="AppTheme" parent="android:Theme.Material.Light"/>
</resources>
AndroidManifest.xml is the place where the custom theme is put to use.
<application
android:theme="#style/AppTheme"
...

Configure Eclipse for Material Design

How do I configure My App to use Material Theme. I don't wanna use Android Studio because its too slow and freezes a lot. I have read the instructions from answer to similar question.
I followed the steps but I didn't get values-21 folder as mentioned in the answer. What can I do now?
There is no difference at project folders structure in this case in Eclipse and AS, maybe you just can't get right preview at Eclipse.
I'm assuming that you currently have a folder res/values that has a file styles.xml which contains your apps theme. Manually create a folder res/values-v21 and copy your styles.xml into it. Modify the new file now so that it uses the material theme as its parent.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="#android:style/Theme.Material">
<!-- Customize your theme here. -->
</style>
</resources>
Now when your app is run on a device/emulator running API 21+ it will use the Material theme.

Android - apply theme from older API

I would like to deploy my app on APIs 8-17. However, for purely aesthetic reasons I would like to apply the default theme as it appears on api 8 as the theme for the app across all API levels.
For example, the older theme has an edittext that has an orangeish border around it, whereas the newer them uses a borderless blue line.
By limiting which APIs i deploy too I have been able to accomplish this but that isn't really a solution.
Does anyone know how this can be accomplished?
Thanks
Update
For whatever reason applying "Theme" as the theme did not force it to revert to the "Theme" theme, but instead left it as the default Holo. Using the answers below I simply called "Theme" as the parent in my custom theme (without altering any of its attributes) and set it as my application theme in the manifest. This solved it.
In your res/values directory, you can have a themes.xml file with:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme" parent="#android:Theme">
</style>
</resources>
Your app theme will now subclass from default Theme instead of Theme.Holo and you should be able to get older theme on newer android versions as well.
If you're using the default theme, it will be different between the API levels. However in the styles, you can create a custom Theme, modify an existing Theme or give a different Theme to each different API of your choice.

Difference between pre ICS and post ICS Holo theme related

I have a couple of app that were created with Android 1.6 and after. The problem is when I run these app on recent Android (device or simulator) like ICS, I don't have the Holo theme.
I know i can find a lot of thread on how to specify the theme but when I create a new app now, I have the new theme without any lines of code.
I don't want to have ICS theme on all android version, just ICS theme on ICS, like new holo buttons style on ICS and old grey style for older. Now I just have grey buttons for all versions.
I can create new empty projects and copy all my files into it but there must be a hidden value somewhere to chenge this.
In my manifest I have:
<uses-sdk android:minSdkVersion="3" />
<uses-sdk android:targetSdkVersion="14" />
What can be the difference between old and new created projects ?
What I'm understanding is that you want your app to switch between the legacy (classic) theme and the new Holo theme based on API version.
First, in your values (res/values) folder make a new xml. Call it styles.xml. It should contain these lines:
<resources>
<style name="AppTheme" parent="#android:style/Theme.Black"/>
</resources>
Then make a new folder in res called values-v11. In this new folder make another new xml. Also name it styles.xml This file should contain these lines:
<resources>
<style name="AppTheme" parent="#android:style/Theme.Holo"/>
</resources>
Then in your AndroidManifest.xml you Application node should contain this line:
android:theme="#style/AppTheme"
Now on devices with Honeycomb or higher you get the Holo theme and for everything else, you get the old classic theme. You can easily experiment with this to suit your needs - this is the general way to switch between themes based on API version.

Android: How to handle theming for older SDK's

I have an app that is minSDK 10, target's 14. I'd love to use the Light.Holo Theme (if available for device--and falls back to light theme for older device). Is there a way I can do this this?
It seems it defaults to Dark.Holo when you target 14, but when I try to add any other theme, it overwrites it and makes it look older on newer devices.
You need to provide separate styles for both platforms to ensure that the correct style will be found at runtime.
In your res/values/styles.xml file, create the following style:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.MyTheme" parent="#android:style/Theme.Light" />
</resources>
In your res/values-v11/styles.xml file, create the following style:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.MyTheme" parent="#android:style/Theme.Holo.Light" />
</resources>
In your AndroidManifest.xml file, use the following line for your application's theme:
android:theme="#style/Theme.MyTheme"
I think these answers might fit: Set Holo theme in older Android versions?
Basically they're recommending copying the themes into your own project so they're available to all users

Categories

Resources