Android Transparent status bar

Source: Internet
Author: User

The Android transparent status bar is only available after 4.4.

There are two ways of setting it:

1.

        if (Build.VERSION.SDK_INT >= build.version_codes. KITKAT) {            //transparent status bar            GetWindow (). Addflags (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);            Transparent navigation bar           GetWindow (). Addflags (WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);        }
This setting causes the view to pan to the top, which can be resolved by the following method, set in the layout file (the Scarlet Letter section):


<relativelayout xmlns:android= "http://schemas.android.com/apk/res/android"    xmlns:tools= "http// Schemas.android.com/tools "    android:layout_width=" match_parent "    android:layout_height=" Match_parent "    android:paddingleft= "@dimen/activity_horizontal_margin"    android:paddingright= "@dimen/activity_ Horizontal_margin "    android:background=" #ff0000 "    android:paddingtop=" @dimen/activity_vertical_margin "    <span style= "color: #FF0000;" >android:fitssystemwindows= "true"    android:cliptopadding= "true" </span>    android:paddingbottom= " @dimen/activity_vertical_margin "    tools:context=". Mainactivity ">
Fitssystemwindows: Sets whether the System window layout is considered when the layout is applied and, if true, adjusts the system window layout to fit your custom layout. For example, the system has a status bar, the application also has a status bar. Look at your layout code, precisely in the definition of the title bar style, so the use of this line of code.

Cliptopadding了是否允许ViewGroup在padding中绘制,该值默认为true,即不允许.

2. Set in theme:


    Android:theme= "@android: Style/theme.devicedefault.light.noactionbar.translucentdecor"                android:theme= "@ Android:style/theme.holo.light.noactionbar.translucentdecor "                android:theme=" @android: style/ Theme.Holo.NoActionBar.TranslucentDecor "
Three kinds are available, if you use a custom theme, simply add the following properties in the Values-19 file:

    <style name= "Appbasetheme" parent= "Android:Theme.Holo.Light.DarkActionBar" >            <!--API Theme Customizations can go here. --            <item name= "Android:windowtranslucentstatus" >true</item>            <item name= "Android: Windowtranslucentnavigation ">true</item>        </style>




Android Transparent status bar

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.