android5.x above status bar transparency issues

Source: Internet
Author: User

1, first in the style of the statusbarcolor set to transparent as follows

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

2. Use the Material design page to make full-screen display

GetWindow (). Getdecorview (). setsystemuivisibility (                | View.system_ui_flag_layout_fullscreen);

3, for my own situation, I put a picture on the top of the toolbar, the default image will be displayed under the status bar, at this time in the ImageView jacket a framelayout set

Android:fitssystemwindows is true, the picture is displayed in full screen and pressed below the status bar.
/In this case, you need to set a margin value for the status bar height  , otherwise, the toolbar will overlap with the status bar, and the text in the toolbar is not displayed toolbar. Because of the 5.0 new feature, when toolbar moves up, it is displayed by default under the status bar
When we do a full-screen display, the toolbar will overlap with the status bar. At this point, you can set the margintop of the toolbar to the status bar height (6.0 is 25DP below 24DP)
<?xml version= "1.0" encoding= "Utf-8"? ><android.support.design.widget.coordinatorlayout xmlns:android= " Http://schemas.android.com/apk/res/android "Xmlns:app= "Http://schemas.android.com/apk/res-auto"Xmlns:tools= "Http://schemas.android.com/tools"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Tools:context= "Com.chuangyuan.qdocument.activity.AboutActivity" > <android.support.design.widget.AppBarLayout Android:id= "@+id/appbar"Android:layout_width= "Match_parent"Android:layout_height= "300DP"Android:theme= "@style/themeoverlay.appcompat.dark.actionbar" > <android.support.design.widget.CollapsingToolbarLayout Android:id= "@+id/collapsing"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"App:contentscrim= "? Attr/colorprimary"App:layout_scrollflags= "Scroll|exituntilcollapsed" > <framelayout//outer sleeve framelayout and set Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"android:fitssystemwindows= "true" > <ImageView android:layout_width= "Match_parent"Android:layout_height= "230DP"android:src= "@drawable/head"Android:scaletype= "Centercrop"App:layout_collapsemode= "Parallax"/> </FrameLayout> <Android.support.v7.widget.Toolbar Android:id= "@+id/toolbar"Android:layout_width= "Match_parent"Android:layout_height= "? Attr/actionbarsize"App:layout_collapsemode= "Pin"Android:background= "@android: Color/transparent"Android:layout_margintop= "24DP"//You need to set a margin value of the status bar height for toolbar, otherwise, the text in the toolbar will not be displayed completely. /> </android.support.design.widget.CollapsingToolbarLayout> </android.support.design.widget.appbarla Yout> <Android.support.v4.widget.NestedScrollView Android:id= "@+id/nested"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"App:layout_behavior= "@string/appbar_scrolling_view_behavior" > <LinearLayout android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "Vertical" > <TextView android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:text= "a ... Stands for many words "/> </LinearLayout> </android.support.v4.widget.nestedscrollview></android.support.desig N.widget.coordinatorlayout>

android5.x above status bar transparency issues

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.