Android 更改操作栏背景和标题颜色

Android 更改操作栏背景和标题颜色,android,android-actionbar,android-xml,android-styles,Android,Android Actionbar,Android Xml,Android Styles,我是Android开发新手。我正在使用的应用程序需要白色的操作栏背景,标题应该是黑色。我使用支持库来降低兼容性 Style.xml <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> </style> 我怎样才能做到这一点?试试这种风格: <style name="AppT

我是Android开发新手。我正在使用的应用程序需要白色的操作栏背景,标题应该是黑色。我使用支持库来降低兼容性

Style.xml

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
     <!-- Customize your theme here. -->
</style>

我怎样才能做到这一点?

试试这种风格:

<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
    <item name="android:actionBarStyle">@style/ActionBar</item>
    <item name="android:buttonStyle">@style/Button</item>
    <item name="android:editTextStyle">@style/EditText</item>
    <item name="android:windowBackground">@android:color/black</item>
</style>

<style name="ActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
    <item name="android:backgroundStacked">@color/core_other_light</item>
    <item name="android:backgroundSplit">@color/core_other</item>
    <item name="android:background">#00ff00</item>
</style>

@样式/操作栏
@样式/按钮
@样式/编辑文本
@android:彩色/黑色
@颜色/核心\u其他\u灯
@颜色/核心/其他
#00ff00
您可以找到更多信息,并尝试以下样式:

<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
    <item name="android:actionBarStyle">@style/ActionBar</item>
    <item name="android:buttonStyle">@style/Button</item>
    <item name="android:editTextStyle">@style/EditText</item>
    <item name="android:windowBackground">@android:color/black</item>
</style>

<style name="ActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
    <item name="android:backgroundStacked">@color/core_other_light</item>
    <item name="android:backgroundSplit">@color/core_other</item>
    <item name="android:background">#00ff00</item>
</style>

@样式/操作栏
@样式/按钮
@样式/编辑文本
@android:彩色/黑色
@颜色/核心\u其他\u灯
@颜色/核心/其他
#00ff00

您可以找到更多信息和。

样式:主应用程序主题

<style name="MyAppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">

    <item name="android:actionBarStyle">@style/CustomActionBarStyle</item>
  <!-- Support library compatibility -->  
    <item name="actionBarStyle">@style/CustomActionBarStyle</item>

</style>

有关更多信息,请参阅@Santosh Shinde post中发布的链接

<style name="MyAppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">

    <item name="android:actionBarStyle">@style/CustomActionBarStyle</item>
  <!-- Support library compatibility -->  
    <item name="actionBarStyle">@style/CustomActionBarStyle</item>

</style>

有关更多信息,请参阅@Santosh Shinde post中发布的链接

使用此链接更改标题
颜色

ActionBar actionBar = getActionBar();
         actionBar.setTitle(Html
         .fromHtml("<font color='#ffffff'> Now playing </font>"));


使用此选项可更改标题
颜色

ActionBar actionBar = getActionBar();
         actionBar.setTitle(Html
         .fromHtml("<font color='#ffffff'> Now playing </font>"));


您是否将新工具栏用作操作栏?请检查下面的链接以在不推荐的操作栏上使用工具栏我没有使用工具栏您是否将新工具栏用作操作栏?请检查下面的链接以在不推荐的操作栏上使用工具栏我没有使用工具栏谢谢,但我在使用min sdk作为9更改您的min时出错11I客户端的sdk级别需要9,如果您使用的是ActionBarCompat库,则应使用相同的方法。唯一的区别是您应该更改actionBarStyle(不带android:prefix),谢谢,但我在使用min sdk时遇到了错误9将您的min sdk级别更改为11I client needs 9如果您使用ActionBarCompat库,则应使用相同的方法。唯一的区别是您应该更改actionBarStyle(不带android:prefix)
getActionBar().setBackgroundDrawable(
         new ColorDrawable(Color.parseColor("#000000")));