2

您好,我正在为我的应用程序制作自定义主题。我想为应用程序的其余部分(在 ActionBar 下方)有一个自定义的 ActionBar 和背景。我想知道如何做背景。现在我有:

<style name="MyTheme" parent="android:Theme.Holo">
    <item name="android:actionBarStyle">@style/dActionBar</item>
</style>

<style name="dActionBar" parent="@android:style/Widget.Holo.ActionBar">
    <item name="android:background">#4C721D</item>
    <item name="android:textColor">#FFFFFF</item>    
</style>

我只需要做<item name-"android:background"></item>还是MyTheme必须创建另一个style?创建这个之后,我需要把它放在 res/styles 文件夹中吗?还有什么 API 限制,如果有的话?

4

2 回答 2

1

不要忘记将您的主题应用到您的AndroidManifest.xml.

<application android:theme="@style/CustomActivityTheme" ... />

您可以在此处找到有关设置操作栏样式的所有信息。

要使用漂亮的 Holo 外观来设置 ActionBar 的样式,请试试这个网站

希望这可以帮助!

于 2013-06-18T14:28:36.673 回答
1

尝试在 Style.xml 文件中使用以下代码

<resources>
    <style name="Theme.Sample" parent="Theme.AppCompat">

   <item name="android:colorBackground">@color/primary_material_dark</item>
   <item name="actionBarTheme">@color/colorGray</item>
   </style>
</resources>

只需使用android:colorBackground作为项目名称来定义背景颜色,如下所示:

    <item name="android:colorBackground">@color/primary_material_dark</item>

希望得到您的答复,谢谢。

于 2017-02-11T07:06:28.100 回答