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

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.

Related

Ripple color on ImageCardView in Android TV

I am using the Leanback library for an Android TV application, and I am using the typical BrowseFragment that uses ImageCardViews for navigation. The ImageCardViews show a ripple effect when clicked: a semi-opaque white circle starts in the middle and grows to fill the View.
I am trying to change the ripple color to match my app's primary color. My application uses a custom Theme that inherits from Theme.Leanback, and I thought (based on e.g. https://stackoverflow.com/a/31922339/925478) that I could change the ripple color by overriding the colorControlHighlight attribute in the theme:
<style name="MyLeanback" parent="Theme.Leanback">
<item name="colorControlHighlight">#color/red</item>
</style>
However, this does not seem to have any effect. When I click and hold an ImageCardView, I still see the semi-opaque white circle.
How can I change the color of the ripple?
The solution was maddeningly easy:
<style name="MyLeanback" parent="Theme.Leanback">
<item name="android:colorControlHighlight">#color/red</item>
</style>
Note the android: prefix, which is required to override themes when not using AppCompat.
I had been dissuaded by the editor from including that prefix; it complained that it requires API21 (my application targets a lower version because it is a single .APK for mobile and TV platforms).

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.

Android - Make a custom titlebar that uses the device's current titlebar theme

I'm trying to make a custom titlebar for my first Android application.
While I can find lots on the web about how to make them so you can change colours etc, I want my titlebar to look the same as the "standard" titlebar, but with a button that I can configure. This means copying the device's currently active themes to be able to style it in exactly the same way.
Not all devices simply use a gradient in the titlebar style, so adding a gradient (as suggested in other SO questions) doesn't really make sense.
Does anyone have any pointers how to read the style information?
try to extend an existing theme e.g.
create your own style which can ofcourse extend from existing from an existing theme. change the windowNoTitle to true.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="noTitleBarStyle" parent="android:Theme.Black">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">#color/darkGrey</item>
<item name="android:colorForeground">#ff3333</item>
</style></resources>
or try to do it runtime as discussed here
Android - change custom title view at run time
I hope this helps.

Does Holo Theme work with custom titlebar?

I've got an application that draws a custom title bar using the following style for the application theme:
<style name="App_Theme" parent="android:Theme">
<item name="android:windowTitleSize">30dip</item>
<item name="android:windowTitleBackgroundStyle">#style/App_TitleBackground</item>
</style>
This does not give me the holo theme. So I set the to parent="#android:style/Theme.Holo". This crashes the application with the following error:
E/AndroidRuntime(2048): Caused by: android.util.AndroidRuntimeException: You cannot combine custom titles with other title features
Is it disallowed to use custom title bar using:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
Or am I missing something here?
PS:
The code works perfectly fine with the parent set to "Android:Theme".
I'm using API Level 14
Let your activity use a theme with following attribute:
<item name="android:windowActionBar">false</item>
mido is correct
<item name="android:windowActionBar">false</item>
is the solution when using #android:style/Theme.Holo (default for ICS).
One observation, if you use #android:style/Theme.Holo.NoActionBar change it back to the default #android:style/Theme.Holo.
Mostly for the benefit of future visitors, one cannot use Window.FEATURE_CUSTOM_TITLE with Holo themes. Setting android:windowActionBar is not what I wanted, since I wanted a title bar, although a customized one.
My workaround, was to requestWindowFeature(Window.FEATURE_NO_TITLE) and add another layout that looked like a titlebar in my activity. That way, I get the best of both worlds.

Categories

Resources