Transparent ActionBar is not working

2019-07-23 03:35发布

问题:

I'm not able to set the transparency or any other color to the Actionbar. My style.xml:

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

</style>
<style name="thin_actionbar_style" parent="android:Widget.Holo.ActionBar">
    <item name="android:height">60dp</item>
    <item name="android:homeAsUpIndicator">@drawable/ic_drawer</item>
    <item name="android:background">@color/translucent_control</item>
</style>

tranlucent_color: like the bar in the screenshot below. Looks like this. It's just grey:

Please help me!

回答1:

try this code

<item name="android:background">@null</item>

If this does'nt helps you, Check this link with this Code

Call setStackedBackgroundDrawable() on your ActionBar

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

OR this link , this code

<style name="MyTheme" parent="Theme.Sherlock"> ... <item name="windowActionBarOverlay">true</item> <!-- for ActionBarSherlock --> <item name="android:windowActionBarOverlay">true</item> </style>

For making ActionBar Transparent.Hope this helps.



回答2:

for back ground you can use :

 <item name="android:background">@android:color/transparent</item>

i hope it will help