造型动作条福尔摩斯 [英] Styling ActionBar Sherlock
问题描述
我想定制我的福尔摩斯行动起来吧,但没有我code在我style.xml是公认的。
I'm trying to customize my sherlock action bar, but nothing that I code in my style.xml is recognized.
在我的清单文件:
android:theme="@style/Theme.Sherlock"
我的style.xml:
My style.xml:
<resources>
<style name="Theme.MyAppTheme" parent="Theme.Sherlock">
<item name="android:actionBarStyle">@style/Theme.MyAppTheme.ActionBar</item>
</style>
<style name="Theme.MyAppTheme.ActionBar" parent="Widget.Sherlock.ActionBar">
<item name="android:background">#222222</item>
<item name="android:height">64dip</item>
<item name="android:titleTextStyle">@style/Theme.MyAppTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="Theme.MyAppTheme.ActionBar.TitleTextStyle" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#fff</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">32sp</item>
</style>
我打电话给我的动作条是这样的:
I'm calling my actionbar this way:
public class MainActivity extends SherlockActivity {
com.actionbarsherlock.app.ActionBar actionbar;
...
actionbar = getSupportActionBar();
... }
有一个在展示动作条没有问题,但同样没有显示任何定制$ C $光盘style.xml,有人可以帮我吗?谢天谢地了。
There is no problem in showing the actionbar, but the same does not show any customization coded in style.xml, can someone help me? Thankful.
推荐答案
这是因为你申请相同的原始风貌清单文件中安卓主题=@风格/ Theme.Sherlock
不作任何区别。你有prepared自定义样式名为 Theme.MyAppTheme
,其母公司为 Theme.Sherlock
。所以,你需要声明自定义风格(Theme.MyAppTheme)在你的manifest文件如安卓主题=@风格/ Theme.MyAppTheme
。即使你有没有包括Android的preFIX属性太像下面像其他回答者也表示。希望这可以帮助。甚至你可以参考<一个href="http://stackoverflow.com/questions/14104091/is-there-a-way-to-set-actionbar-backgound-by-image-in-android/14104260#14104260">this了。
It's because you are applying the same original style in the manifest file android:theme="@style/Theme.Sherlock"
which doesn't make any difference. You have prepared the custom style with name Theme.MyAppTheme
, having parent as Theme.Sherlock
. So, you need to declare your customized style(Theme.MyAppTheme) in your manifest file like android:theme="@style/Theme.MyAppTheme"
. Even you have to include without android prefix attributes too like below as the other answerer also said. Hope this helps. Even you can refer this too.
<style name="Theme.MyAppTheme" parent="Theme.Sherlock.Light">
<item name="android:actionBarStyle">@style/Theme.MyAppTheme.ActionBar</item>
<item name="actionBarStyle">@style/Theme.MyAppTheme.ActionBar</item>
</style>
<style name="Theme.MyAppTheme.ActionBar" parent="Widget.Sherlock.ActionBar">
<item name="android:background">#222222</item>
<item name = "background">#222222</item>
<item name="android:height">64dip</item>
<item name="height">64dip</item>
<item name="android:titleTextStyle">@style/Theme.MyAppTheme.ActionBar.TitleTextStyle</item>
<item name="titleTextStyle">@style/Theme.MyAppTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="Theme.MyAppTheme.ActionBar.TitleTextStyle" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#fff</item>
<item name="textColor">#fff</item>
<item name="android:textStyle">bold</item>
<item name="textStyle">bold</item>
<item name="android:textSize">32sp</item>
<item name="textSize">32sp</item>
</style>
这篇关于造型动作条福尔摩斯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!