Amelia@Amazon avatar image
Amelia@Amazon posted

Ensuring widget text is visible in your apps with Android 5.0 theme changes


Android L changed the default theme, meaning if you hardcoded text within your widgets you will need to change your app to reflect Google's new UI decisions


Hardcoded white text will not display properly as Google changed the defaults from white on black to black on white.


This problem can be addressed one of a couple of ways.

If you wish to keep your current codebase untouched create a values-21 directory within your app, and build out a styles and/or colors XML file specific to your app running in Lollipop. From here you have two choices, you can either use the AppCompat library and adopt the AppCompat.Theme as your parent theme to keep your UI consistent with itself, or you can create a new style to look more natural within Lollipop. This will allow for you to be able to work within Google's new style while not breaking existing code.

Alternatively, you can migrate over to AppCompat.Theme for your entire app and it will remain consistent across all versions of Android.

The default text color can remain unchanged within your apps styles, or the text and background colors can be explicitly set. Ensure that a readable foreground and background are selected and consistently applied within your app.

For reference, please refer to: Styles and Themes | Android Developers: AppCompat v21 Material Design for pre-Lollipop devices:

Keywords: Material Design, UI, Widgets, UX, Graphics


10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.



brizzlebrazzle contributed to this article