2

我想更改我的 actionbarsherlock 操作栏的文本样式/字体大小/字体颜色。我将在下面展示我的尝试,但它只显示错误“ error: Error: No resource found that matches the given name (at 'android:textColor' with value '@color/black').”和“ error: Error: No resource found that matches the given name (at 'android:textSize' with value '@dimen/20dp').”有人可以告诉我它是如何完成的吗?

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="ABSTheme" parent="Theme.Sherlock.Light.ForceOverflow">
    <item name="android:actionBarStyle">@style/ABSTheme.ActionBar</item>
    <item name="actionBarStyle">@style/ABSTheme.ActionBar</item>
</style>

<style name="ABSTheme.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid">
    <item name="android:displayOptions">showHome|useLogo</item>
    <item name="displayOptions">showHome|useLogo</item>
    <item name="titleTextStyle">@style/ABSTheme.ActionBar.TextAppearance</item>
</style>

<style name="ABSTheme.ActionBar.TextAppearance" parent="@style/TextAppearance.Sherlock.Widget.ActionBar.Menu">
      <item name="android:textSize">@dimen/20dp</item>
      <item name="android:textColor">@color/black</item>
 </style>
</resources>
4

1 回答 1

2

wdziernia是对的。对于尺寸,您可以只做 20dp,对于颜色,您可以指定一个十六进制颜色,如#ffffff。

如果您想在其他 xml 文件中使用预定义的值,您可以通过在 values/colors.xml 中创建一个如下所示的 xml 文件来创建自己的值:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="black">#ffffff</color>
</resources>

然后在您的样式 xml 文件中,您可以引用 @color/black。在这种情况下,您可以只使用 android 内置的黑色:@android:color/black而不是@color/black(@android:使用 android 内置。

You can do a similar thing specifying dimensions by name in a separate xml file as well.

于 2012-09-01T03:30:46.777 回答