Properly set SeekBar style for Holo and pre-Holo APIs - android

After setting SeekBar with Holo style, I got warning that it's not supported pre-Holo APIs.
If I leave it this way, will this crash the app or pull pre-Holo style anyway? It does not crash on the emulator and I don't have 2.3.3 device.
The reason for asking his is odd behaviour. I tried to manually set style for Holo and pre-Holo using res/values-v11/ directories and placing styles.xml in each and setting the style of SeekBar to style="#style/settings_seekbar" .
Style for API 11+ looked like this
<style name="settings_seekbar">
<item name="android:seekBarStyle">#android:style/Widget.Holo.SeekBar</item>
</style>
and style for APIs older than 11 looked like this
<style name="settings_seekbar">
<item name="android:seekBarStyle">#android:style/Widget.SeekBar</item>
</style>
So it looked like this would work. But on either device with Android 4.0+, I don't see Holo's theme, but the old thick-yellow theme.
If this is the proper way of settings styles (in case the first solution will crash a device), where did I make a mistake thus Holo theme never appeared on newer devices?

It seems we can safely use a theme from the upper SDK because I found no indicators that it will ever crash the app.
If the theme does not exist, Android will use the appropriate lower-level theme.
The error we can see on the image is just a warning that UI will not look the same in the SDKs which do not support this theme.

Related

BoxInsetLayout on Android wearable round screen not working with Theme.AppCompat

I'm developing an app for Android wearables. I want to create a layout working on both round and square screens. Therefore I'm using BoxInsetLayout.
I also want to use a CheckBox from Material Theme. Therefore I'm using a custom theme derived from Theme.AppCompat.Light.
<style name="AppTheme" parent="#style/Theme.AppCompat.Light">
The problem is that BoxInsetLayout is not working properly on round screens. I'm having the same issue as described here but the solution mentioned there is not working for me. The relevant code parts are the same except the theming part.
When I switch the theme to Theme.DeviceDefault I only get the CheckBox from Holo.
Try adding:
<item name="android:windowOverscan">true</item>
to your theme. It is necessary for dispatching insets.

Translucent Status Bar on Kitkat, Tinted Status Bar on Lollipop

I've searched for a solution, but haven't found one yet.
I'm currently in the process of creating an Android app and my team wants to keep the experience of our app the same across the recent Android versions. We're using the Support v7 library, so most of the Material Design elements can be used in our app, but we're kinda struggling to find a replacement for the tinted status bar. We've got a nice bar on Lollipop, but Kitkat is stuck with the ugly black bar and we'd really like to change that.
We were thinking about a translucent bar for pre-Lollipop devices, but we're not sure on how to approach that. I've tried copying the styles.xml to a new folder, values-v19, and adding
<item name="android:windowTranslucentStatus">true</item>
<item name="android:fitsSystemWindows">true</item>
to the styles, but this is also applied to my phone running Android 5.0.2, strangely enough.
Do you happen to know how to fix this or another method to create a similar effect? I'm new to Android, so detailed explanations will be appreciated.
Try adding
<item name="android:windowTranslucentStatus">false</item>
<item name="android:fitsSystemWindows">false</item>
to either values/styles.xml or values-v21/styles.xml.
When you define a style for a certain API level it will be applied not only to that version, but also to all higher versions, unless explicitly specified otherwise.

Android application Theme overriding view theme

I have been developing an Android app for quite some time now and almost everything is how it's supposed to be. However, I'm having some issues with themes for some views. My application uses a AppCompat.Light based theme as shown bellow:
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar"></style>
Everything looks white and clean, but I have one specific screen that is kind dark. So I created the following theme for some EditText fields:
<style name="InputField" parent="Theme.AppCompat"></style>
in order to make the input fields have white colors. I then run the application on devices with different Android versions. On a smartphone with Android 5.0.2, everything looks as I expected. On a smartphone with android 4.4.4, however, the input is dark. I even tried to change the theme of the input field theme to
<style name="InputField" parent="Theme.Holo"></style>
or
<style name="InputField" parent="#android:style/Widget.Holo.EditText"></style>
in the values-v19 styles, but it still looks dark. If I change the application theme to
<style name="AppBaseTheme" parent="Theme.AppCompat.NoActionBar"></style>
the input fields look as they should, but the entire rest of the app is dark themed and it's not what I want. I can only assume that application theme is having some influence over my views theme, even though I explicitly specified the theme they should use. The same behavior happens on a smartphone with android 4.2.2.
System provided styles doesn't define used colors, they have only references to a theme attributes. Colors are defined the theme, thus, it not enough, if you set parent to some system style.
Starting API 21 (5.0) you can override theme for specific views (or styles) by setting attribute android:theme. For older versions you will need to define specific colors and drawables in your style.

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.

Blurry text on EditText on SonyEricsson phones - Android

I updated my app for Android 4.0 to make it more futureproof,
after the update, i started to get reports from SE-users that their edittext and textviews are all blurry, the FONT is blurry (which makes me think that this is a SE-problem).
Even if i change the font, it is still blurry.
Does anyone know a solution or have experience the same?
Can't show you any screenshots of this...
Regards.
This is a styling issue.
I had my edit text inherit the Holo theme which caused the text to blur on pre ICS devices, this may be pre HoneyComb, but I haven't been able to check.
values/styles.xml
<!-- Base style for the edit text, api dependant -->
<style name="Widget.EditBase" parent="#android:style/Widget.EditText"></style>
values-v11/styles.xml
<!-- Base Style for the edit text -->
<style name="Widget.EditBase" parent="#android:style/Widget.Holo.EditText"></style>
This fixed it instantly for me - v11 being HoneyComb 3.0 which should be fine as the Holo theme is available from then onwards.
Can't explain why, but assuming it must be with the Widget.Holo.EditText style pointing to the wrong resource pre ICS/HC.
Hope this helps.
Cheers,
Chris
I had this same issue affecting different phones. What my problem was is that my custom theme was using a parent theme from ICS which wasn't available on older phones. My solution was to have a values-v11/themes.xml for ICS devices and values/themes.xml for older android phones.

Categories

Resources