0

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: screenshot 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.

ZzZombo
  • 1,082
  • 1
  • 11
  • 26

1 Answers1

0

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>
R7G
  • 1,000
  • 1
  • 10
  • 15
  • Can you clarify why and how does it fix the issue? – ZzZombo Aug 22 '18 at 06:42
  • you are using default value of OS so , in case of custom OS values may override . so it wil be better to use your own value of resources. – R7G Aug 22 '18 at 06:53
  • have you change the AppTheme name to AppTheme_custom at it's usage also. – R7G Aug 22 '18 at 08:16
  • Yes, I did rename the theme, even tho it isn't clear to me why would that matter. – ZzZombo Aug 22 '18 at 08:27
  • to avoid conflicts with OS value , if it is. Just Try one more thing change the TextView in AppCompatTextView . – R7G Aug 22 '18 at 08:40
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/178516/discussion-between-zzzombo-and-r7g). – ZzZombo Aug 22 '18 at 09:35