I have created a custom theme for my Android application. In the designer and several real test devices they all show correctly, but a particular device doesn't seem to apply parts of the theme correctly. It looks like for some reason anything inactive/disabled uses the styling for the opposite state. Example: The blue button is disabled, and the text in the input control is actually a hint, but they aren't grayed out despite that on the problematic device.
The theme itself didn't change much from the base theme:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar" >
<item name="android:colorForeground">@android:color/background_light</item>
<item name="android:textColorPrimary">@android:color/primary_text_light</item>
<item name="colorAccent">@android:color/holo_blue_bright</item>
</style>
The device runs Android 6.0, the app targets API level >= 19. Another test device from a different manufacturer with the same Android version works correctly.
I have tried a few proposed solutions, like copying the theme into values-v11
and values-v14
as per https://stackoverflow.com/a/13443946/4429472 , but none of them fixed the problem.
EDIT: the phone in question is Leagoo M8, with Freeme OS.
in your res>value>colours.xml
add this
<color name="colorForeground">#ffffffff</color>
<color name="colorAccent">#FF4081</color>
<color name="holo_blue_bright">#ff00ddff</color>
<color name="bright_foreground_light_disabled">#80000000</color>
<color name="bright_foreground_light">#ff000000</color>
create a selecter in your drawable folder with name selector_text.xml past this code
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="@color/bright_foreground_light_disabled"/>
<item android:state_window_focused="false" android:color="@color/bright_foreground_light"/>
<item android:state_pressed="true" android:color="@color/bright_foreground_light"/>
<item android:state_selected="true" android:color="@color/bright_foreground_light"/>
<item android:state_activated="true" android:color="@color/bright_foreground_light"/>
<item android:color="@color/bright_foreground_light"/> <!-- not selected -->
</selector>
update your style with this also rename the style AppTheme_custom and do change in manifest and where ever you used this theme.
<style name="AppTheme_custom" parent="Theme.AppCompat.Light.NoActionBar" >
<item name="android:colorForeground">@color/colorForeground</item>
<item name="android:textColorPrimary">@drawable/selector_text</item>
<item name="colorAccent">@color/holo_blue_bright</item>
</style>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.