article

Amelia@Amazon avatar image
Amelia@Amazon Posted · · edited ·

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

Summary

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

Issue

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

Resolution

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: http://developer.android.com/guide/topics/ui/themes.html AppCompat v21 Material Design for pre-Lollipop devices: http://android-developers.blogspot.com/2014/10/appcompat-v21-material-design-for-pre.html

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

KB_0029

androidlollipop
10 |2000 characters needed characters left characters exceeded

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

Article

Contributors

brizzlebrazzle contributed to this article