我似乎无法弄清楚如何将操作栏的颜色更改为白色而不是默认的黑色。
<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>
任何帮助?
答案 0 :(得分:0)
在本文中,您将了解如何自定义ActionBar
以及更多内容
http://developer.android.com/guide/topics/ui/actionbar.html#AdvancedStyles
答案 1 :(得分:0)
只需使用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>"));