【问题标题】:Changing text color in action bar? [duplicate]更改操作栏中的文本颜色? [复制]
【发布时间】:2014-02-05 01:43:22
【问题描述】:

我似乎无法弄清楚如何将操作栏的颜色更改为白色而不是默认的黑色。

<resources>
    <style name="ActionBarOrange" parent="@android:style/Theme.Holo.Light.DarkActionBar">
        <item name="android:actionBarStyle">@style/MyActionBar</item>
        <item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
    </style>

    <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
        <item name="android:background">@color/orange</item>
    </style>

</resources>

有什么帮助吗?

【问题讨论】:

标签: android android-actionbar


【解决方案1】:

在本文中,您将了解如何自定义 ActionBar 以及更多内容

http://developer.android.com/guide/topics/ui/actionbar.html#AdvancedStyles

【讨论】:

    【解决方案2】:

    只需使用 HTML:

    String htmlColor;
    Color orange = getResources().getColor(R.color.orange);
    int alpha = Color.alpha(orange);
    if (alpha == 0)
        htmlColor = String.format(Locale.US, "#%06X", (0xFFFFFF & orange));
    else {
        int red = Color.red(orange);
        int green = Color.green(orange);
        int blue = Color.blue(orange);
        if (Build.VERSION >= 18) //KITKAT first provided CSS3 support
            htmlColor = String.format(Locale.US, "rgba(%d,%d,%d,%d)", red, green, blue, alpha);
        else 
            htmlColor = String.format(Locale.US, "#%06X", (0xFFFFFF & Color.argb(0, red, green, blue)));
    }
    
    getActionBar()/* or getSupportActionBar() */.setTitle(Html.fromHtml("<font color=\"" + hexColor + "\">" + getString(R.string.app_name) + "</font>"));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-13
      • 2014-12-24
      • 1970-01-01
      • 2015-07-11
      相关资源
      最近更新 更多