4

I'm building a music app, which has an ongoing notification. I meet the text color problem of notifications on Galaxy S with 2.3.3. My code is:

in layout/notification.xml

<LinearLayout android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:orientation="vertical">

    <TextView android:id="@+id/notifbar_trackname"
        style="@style/NotificationTitle"
        android:focusable="true" android:singleLine="true"
        android:layout_gravity="left" android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TextView android:id="@+id/notifbar_artist"
        style="@style/NotificationText"
        android:layout_gravity="left" android:scrollHorizontally="true"
        android:ellipsize="end" android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TextView android:id="@+id/notifbar_queue"
        style="@style/NotificationText"
        android:layout_gravity="left" android:scrollHorizontally="true"
        android:ellipsize="end" android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</LinearLayout>

in values-v9/styles.xml

<style name="NotificationText" parent="android:TextAppearance.StatusBar.EventContent" />
<style name="NotificationTitle" parent="android:TextAppearance.StatusBar.EventContent.Title" />

I thought the text will be switched to white-based since Galaxy S has a dark grey background, but it keeps showing black texts. But other apps handle it fine, so there should be a way to do.

Does anyone know how to get the "default status bar text color" on Galaxy S? Thank you!

Romulus Urakagi Ts'ai
  • 3,699
  • 10
  • 42
  • 68
  • What is your problem exactly? What do you want to do? Why don't you just *don't* set the text color and use whatever hte defaults are? – davidcesarino Nov 28 '11 at 03:22
  • My problem is the notification background and text color is device and Android version dependent, and I can't force text color for each devices, since I don't know how most devices doing this. And yes, I'm trying to use the "defaults", and I don't quite know how to write the "defaults". – Romulus Urakagi Ts'ai Nov 28 '11 at 04:06
  • FYI, the folder is supposed to be named values-v9 if I understand correctly, but it still doesn't work for me. – handtwerk Nov 29 '11 at 14:40
  • It sounds like you need a special case for this device, unfortunately. The TextAppearance.StatusBar.* styles were added in Gingerbread to try to ease this pain for future releases (note that Honeycomb switched the platform notification style to white-text-on-black); if there are devices for which this style is wrong you'll need to work around it. – dsandler Dec 06 '11 at 04:26

2 Answers2

0

I used

android:textColor="@android:color/primary_text_light"

There are is another way that uses android:textStyle. See Custom notification layouts and text colors

Community
  • 1
  • 1
pzulw
  • 1,716
  • 15
  • 22
  • Hi, this does work on 3.x and 4.0 devices. I think TextAppearance.StatusBar.EventContent should be the answer, but I don't know what Samsung is doing on this. – Romulus Urakagi Ts'ai Nov 30 '11 at 13:51
0

The best solution I have found so far is the answer by Gaks here for this question:

Custom notification layouts and text colors

However, it is not complete. It will return the color of the title text but not the details text.

Community
  • 1
  • 1
ciscogambo
  • 1,160
  • 11
  • 18
  • Hi - Yes, as my code, I'm using android:TextAppearance.StatusBar.EventContent, but it's still black on Samsung Galaxy S. I have tried to use style="android:TextAppearance.StatusBar.EventContent" directly, but with no luck. – Romulus Urakagi Ts'ai Nov 30 '11 at 08:17
  • No, since Galaxy S is in API 9, and Gaks says it's for older APIs. It seems Samsung changed the notification background, but forget or don't know to change the TextAppearance.StatusBar.EventContent colors. – Romulus Urakagi Ts'ai Dec 01 '11 at 02:46
  • Even though Gaks' comment was about API level 9, this helped me solve a color problem for a user who had a rooted Samsung Epic 4g with API level 9. – ciscogambo Dec 02 '11 at 16:37