【问题标题】:Notification text color in Galaxy S 2.3.3Galaxy S 2.3.3 中的通知文本颜色
【发布时间】:2011-11-28 02:42:34
【问题描述】:

我正在构建一个音乐应用程序,它有一个持续的通知。我在 2.3.3 上遇到了 Galaxy S 通知的文本颜色问题。我的代码是:

在布局/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>

在 values-v9/styles.xml 中

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

由于 Galaxy S 的背景为深灰色,我原以为文本将切换为白色,但它一直显示黑色文本。但是其他应用处理得很好,所以应该有办法。

有谁知道如何在 Galaxy S 上获得“默认状态栏文本颜色”?谢谢!

【问题讨论】:

  • 您的问题到底是什么?你想让我做什么?为什么不设置文本颜色并使用任何 hte 默认值?
  • 我的问题是通知背景和文本颜色取决于设备和 Android 版本,我不能为每个设备强制文本颜色,因为我不知道大多数设备是如何做到这一点的。是的,我正在尝试使用“默认值”,但我不太清楚如何编写“默认值”。
  • 仅供参考,如果我理解正确,该文件夹应该命名为 values-v9,但它仍然不适合我。
  • 不幸的是,听起来您需要为这个设备准备一个特殊的外壳。在 Gingerbread 中添加了 TextAppearance.StatusBar.* 样式,以减轻未来版本的痛苦(请注意,Honeycomb 将平台通知样式切换为 white-text-on-black);如果存在这种样式错误的设备,您需要解决它。

标签: android notifications


【解决方案1】:

我用过

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

还有另一种使用 android:textStyle 的方式。见Custom notification layouts and text colors

【讨论】:

  • 嗨,这确实适用于 3.x 和 4.0 设备。我认为 TextAppearance.StatusBar.EventContent 应该是答案,但我不知道三星在这方面做了什么。
【解决方案2】:

到目前为止,我找到的最佳解决方案是 Gaks 在这里对这个问题的回答:

Custom notification layouts and text colors

但是,它并不完整。它将返回标题文本的颜色,但不返回详细信息文本。

【讨论】:

  • 嗨 - 是的,作为我的代码,我使用的是 android:TextAppearance.StatusBar.EventContent,但在三星 Galaxy S 上它仍然是黑色的。我尝试使用 style="android:TextAppearance.StatusBar .EventContent”直接,但没有运气。
  • 不,因为 Galaxy S 在 API 9 中,而 Gaks 说它适用于较旧的 API。三星似乎更改了通知背景,但忘记或不知道更改 TextAppearance.StatusBar.EventContent 颜色。
  • 尽管 Gaks 的评论是关于 API 级别 9 的,但这帮助我为使用 API 级别 9 的三星 Epic 4g 根深蒂固的用户解决了颜色问题。
猜你喜欢
  • 1970-01-01
  • 2011-12-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多