android - 5.1.1 notification TextView, the correct way to deal with white text? -
i put textview on custom layout notification. colour of textview becomes automatically white. is bug of android? because prior lollipop, notification background used dark colour, white text made sense. on lollipop, default background white, white text invisible.
or supposed set text colour explicitely? putting android:textcolor="@android:color/primary_text_light" made text black, not guaranteed lollipop devices have white notification background, it?
what correct way guarantee text on custom notification visible regardless of background colour of system?
preview on android studio

on actual 5.1.1 device

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="hello, world" /> <button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button 1"/> <button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button 2"/> </linearlayout>
for still looking solution question, think best alternative define style of textview to
textappearance.statusbar.eventcontent prior lollipop, ,
@android:style/textappearance.material.notification.title for apis >=21. this
styles.xml
<style name="notificationtextcolor.title" parent="textappearance.statusbar.eventcontent"></style> v21/styles.xml
<style name="notificationtextcolor.title" parent="@android:style/textappearance.material.notification.title"></style> layout.xml
<textview android:id="@+id/notification_title" android:layout_width="match_parent" android:layout_height="wrap_content" style="@style/notificationtextcolor.title" tools:text="text"/>
Comments
Post a Comment