I need a transparent Actionbar, find the following method to achieve:
1. First, set the Actionbar to float to the main interface.
2. Then, set the background color of the actionbar, transparent or translucent.
So how do you achieve these two steps?
The first step:
Code implementation: in OnCreate: GetWindow (). Requestfeature (Window.feature_action_bar_overlay);
Implemented in style using theme: <item name= "Android:windowactionbaroverlay" >true</item>
Step Two:
Code implementation:
ActionBar ActionBar = getactionbar (); actionbar.setbackgrounddrawable (new colordrawable ( Color.parsecolor ("#33000000"))); // Google's Actionbar is divided into two columns to display, the above code can only set the top Actionbar background color, // To make the following background color consistent, you also need to add a line of code:actionbar.setsplitbackgrounddrawable (new colordrawable (color.parsecolor ("#33000000"));
The use of theme is implemented in the style:
<resources> <style name= "Apptheme" parent= "Android:Theme.Holo.Light.DarkActionBar" > <item Name= "Android:windowactionbaroverlay" >true</item> <!--let Actionbar float and <item Name= "Android:actionbarstyle" > @style/my_actionbar_style</item> </style> <style name= " My_actionbar_style "parent=" @android: Style/widget.holo.light.actionbar "> <!--settings Actionbar background color transparent-- <item name= "Android:background" > #33000000 </item> <item name= "android:backgroundstacked" > #346c36 </item> <item name= "Android:backgroundsplit" > #33000000 </item> </style ></resources>
Android Development (31) Make Actionbar Transparent