布局背景未应用于ActionBar(透明)

时间:2015-12-03 12:30:16

标签: android android-actionbar

我有透明的操作栏,我只是设置了一个背景图片。 我的操作栏现在是透明的,但它没有在操作栏中显示布局背景图像。它显示的是附加的图像enter image description here

请帮帮我:-( 提前致谢!

1 个答案:

答案 0 :(得分:1)

将下方的样式设置为操作栏。

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

 <style name="ActionBar" parent="@android:style/Widget.Holo.ActionBar">
   <item name="android:background">#64000000</item>
</style>

在ActionBar上调用setStackedBackgroundDrawable():

 getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
 ActionBar actionBar = getActionBar();
 actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#330000ff")));
 actionBar.setStackedBackgroundDrawable(newColorDrawable(Color.parseColor("#550000ff")));