i am trying to get my app to use the theme "Theme.Holo", which is the dark theme for android. my app minimum SDK is 9, and i have the Support libraries included from google.
i had my app working with the dark theme, and i have no idea what i changed, now its only light. and ic ant seem to change it.
this was my button before (i want this):
And this is what i have now:
This is my values/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:Theme">
<!--
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>
and this is my res/values-11/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:style/Theme.Holo">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>
and res/values-14/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:style/Theme.Holo">
<!-- API 14 theme customizations can go here. -->
</style>
</resources>
Manifest part that relates to theme,
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
At this point i have no idea why the buttons are showing up as Light theme, i tried Theme.Black as well, it didn't change anything.
as #FD_ pointed out Holo theme is available on ICS and above. I suppose the emulator/device you are testing against has SDK < 11.
If you need backward compatibility for holo theme use HoloEveryWhere library by Prototik.
To use Theme.Holo you have to use at least API Level 11. Please refer this link in the Android Developer Guide.
Try to change the minimum API-Version to 11 in you Android Manifest and it should work.
Related
i have app which was created in android:Theme.Light. i want to change it to Theme.AppCompat.Light.DarkActionBar but i get
no resource found that matches the given name
'theme.appcompat.light.darkactionbar'
I have android-support-v4.jar, when i try add appcompat_v7 i get errors in codes where is something like it R..... Can I add DarkActionBar to this project without problems with codes? Without changes in code?
I have:
<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>
</resources>
I want:
<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="Theme.AppCompat.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
</resources>
Ensure that your application is properly linked with the Support Library, with resources (see documentation here).
And don't forget #style/:
<style name="AppTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
This will prevent the no resource error from occurring.
You might be interested in this tutorial too.
If you're doing this in your manifest, do the following to set the theme for the whole app:
<application
...
android:theme="#style/Theme.AppCompat.Light.DarkActionBar"
...>
in your XML for the specific theme, you need #style, so put the following:
<style name="AppTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
From manifest: min version 14
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
Style:
<style name="AppBaseTheme" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<!--
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:windowBackground">#color/fondoObscuro</item>
<item name="android:actionBarStyle">#style/OnTheGoActionBar</item>
</style>
<!-- general styles for the action bar -->
<style name="OnTheGoActionBar"
parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:titleTextStyle">#style/TitleTextStyle</item>
<item name="android:background">#color/actionBarObscura</item>
<item name="android:actionOverflowButtonStyle">#style/CustomOverflow</item>
</style>
I got the error no resource found, on both styles AppBaseTheme and OnTheGoActionBar
There is very specific reason for having two seperate values folder especially for `theming the app
See as you can see in the code you posted, I am sure that following code is from values\styles.xml
<style name="AppBaseTheme" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<!--
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>
I would like to draw your attention to commented code
Theme customizations available in newer API levels can go in res/values-vXX/styles.xml
The styles.xml is for backward compatibility, you change the parent style
parent="android:Theme.Light" to parent="android:Theme.Holo.Light.DarkActionBar"
which is wrong since android:Theme.Holo.Light.DarkActionBar was introduced in API Level-14, See here Theme_Holo_Light_DarkActionBar Android docs. The Builder looks for Theme.Holo.Light.DarkActionBar , but it is not able to find it, as its applicable to new version and hence you see
I got the error no resource found, on both styles AppBaseTheme and OnTheGoActionBar
Simple move your code for custom styling to values-v14\styles.xml and everything will be fine, don't worry if you don't have style provided in values\styles.xml, untill and unless your minSdkVersion is 14.
I hope you understood it.
I've an app which may be ran from 2.2 to 4.x devices.
When I run this app on 4.x it looks cool, holo style. But when I run it on older devices, it seems to be so much "lighty".
There's a screenshot so you can compare:
This is my manifest:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
And my styles:
<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.Holo.Light.NoActionBar.Fullscreen">
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
It's obvious that holo doesn't exist in 2.3, but then it should render its default device theme, right?
So the input is correct, but the TextView looks too grey.
Any idea?
As someone suggested, I finally created a new folder:
res/values-v11/
On this folder, I've put a file named styles.xml, which is the following:
<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.Holo.Light.NoActionBar.Fullscreen">
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
And the folder res/values/ which will be called for android with api lower than 11, contains a styles.xml and there I've changed the parent template, like this:
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="MyTheme" parent="#android:style/Theme.Light">
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
This ends up like this:
Devices with api higher than 11 -> holo theme
The rest: Theme.Light ("Normal theme")
I have made a spinner in an activity getting called inside a tab layout. The problem is that the items (3 in nos.) are being showing in a separate dialog as in case of a drop down list and not as a spinner. I followed this example. And as shown the picture I was expecting but I am getting this:
& this . I want to show just 3 items inside the spinner and do not want the new dialog for the items to be selected. And I have tried my code both on 2.3.3 and 4.0.3 emulators. Any suggestions?
Thanks
spinner as a dropdown is of HOLO Theme. first image is of HOLO Theme and 2nd and 3rd is not.. holo theme is supported since api level 11..
if you want to apply Holo Theme. set
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="17" />
and styles.XML inside values-v11 folder
<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>
and styles.XML inside values folder
<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.NoTitleBar">
<!--
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>
<style name="progressbar_holo" parent="#android:style/Theme.Light">
</style>
and in AndroidMeanifeast.xml
android:theme="#style/AppTheme"
in application TAG.
OR
follow this 2 links
1. https://github.com/ChristopheVersieux/HoloEverywhere
2. https://github.com/ChristopheVersieux/HoloEverywhere
I want to add small lines under the Edit Texts like the following , How can I do that ?
This is by default look of Edittext in Holo Theme. so just apply Holo Theme.
if you want to apply Holo Theme. set
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="17" />
and styles.XML inside values-v11 folder
<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>
and styles.XML inside values folder
<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.NoTitleBar">
<!--
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>
<style name="progressbar_holo" parent="#android:style/Theme.Light">
</style>
and in AndroidMeanifeast.xml
android:theme="#style/AppTheme"
in application TAG.