Android Development (31) Make Actionbar Transparent

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.