[英]How can I change the ActionBar color with XML in Lollipop?
I just updated my Android SDK to 22. 我刚刚将Android SDK更新为22。
When I make an ActionBar, I'm trying to change the background, but it doesn't work. 当我制作一个ActionBar时,我试图更改背景,但是它不起作用。 Here's my style.xml:
这是我的style.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<!--<item name="actionBarTheme">@style/ThemeOverlay.AppCompat.ActionBar</item>-->
<item name="android:actionBarStyle">@style/ActionBar</item>
</style>
<!--ActionBar-->
<style name="ActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#bf360c</item>
</style>
I've tried many times, but it always shows the dark background. 我已经尝试了很多次,但它始终显示深色背景。 What should I be doing?
我该怎么办?
in your activity try to do this: 在您的活动中尝试执行以下操作:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#bf360c")));
setContentView(R.layout.act_mainactivity);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.