3

My application use white color font which is okay on my phone that has a black theme. But on other phone the notification bar color and the menus background color is white or a light color. Is there any way (beside giving the user the option to chose the color in the app settings) to know what kind of color or dark/light theme use the phone and match the font color ?

N West
  • 6,768
  • 25
  • 40
Alex
  • 2,213
  • 4
  • 32
  • 44
  • 1
    Have a look at [this post](http://stackoverflow.com/questions/4867338/custom-notification-layouts-and-text-colors). It will help you get an idea of what you can and can't do. – Andrei Nov 02 '11 at 15:55

2 Answers2

4

When you use Notification and set the text by using built-in means, the following line creates the layout:

RemoteViews contentView = new RemoteViews(context.getPackageName(),
        com.android.internal.R.layout.status_bar_latest_event_content);

The mentioned layout contains the following View which is responsible for viewing notification text:

<TextView android:id="@+id/text"
    android:textAppearance="@style/TextAppearance.StatusBar.EventContent"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:singleLine="true"
    android:ellipsize="marquee"
    android:fadingEdge="horizontal"
    android:paddingLeft="4dp"
    />

So the conclusion is that the needed style is TextAppearance.StatusBar.EventContent, which definition looks like this:

<style name="TextAppearance.StatusBar.EventContent">
    <item name="android:textColor">#ff6b6b6b</item>
</style>

You should note here that this style doesn't actually reference any of the built-in colors, so the safest way is to apply this style instead of some built-in color.

  • This style is only available from API v9 and above. Any ideas for older APIs? – 3c71 Apr 11 '13 at 09:04
  • 2
    This is just an out-of-date copy-paste rip-off of http://stackoverflow.com/a/4935191/238753. – Sam Aug 14 '15 at 21:50
0

I use android:textAppearance="@style/TextAppearance.AppCompat.Notification.Title" work for me

Azat
  • 1,048
  • 8
  • 9