Android immersive status bar Implementation Details

Source: Internet
Author: User

Android immersive status bar Implementation Details

Introduce immersive compatible libraries in studio
Compile 'com. readystatesoftware. systembartint: 1.0.3'
Eclipse, You can import the corresponding class.

Class 1, compatible with actionbar
Step 1: Set the activity topic android: theme = "@ style/action1_eme"

Step 2: Set the status bar transparency, and then set the immersion color of the status bar

@TargetApi(19)private void setTranslucentStatus(boolean on) {Window win = getWindow();WindowManager.LayoutParams winParams = win.getAttributes();final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;    if (on) {            winParams.flags |= bits;        } else {            winParams.flags &= ~bits;        }        win.setAttributes(winParams);    }
@ Overrideprotected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. activity_main); if (Build. VERSION. SDK_INT> = Build. VERSION_CODES.KITKAT) {setTranslucentStatus (true);} SystemBarTintManager tintManager = new SystemBarTintManager (this); tintManager. setStatusBarTintEnabled (true); // sets the immersed color tintManager. setStatusBarTintResource (R. color. statusbar_bg );}

Step 3: Set to adapt to windows and set the layout File
Android: fitsSystemWindows = "true"
If this parameter is not set, the application ui will be topped up and pushed to the system ui.
OK

Activity Without actionbar
Step 1: Set the topic, android: theme = "@ style/FullBleedTheme"

Or
Only Theme. AppCompat. NoActionBar themes can be set with toolbar.

Step 2: Same as step 2.
Set the status bar transparency + color

mTintManager = new SystemBarTintManager(this);mTintManager.setStatusBarTintEnabled(true);mTintManager.setNavigationBarTintEnabled(true);  mTintManager.setStatusBarTintResource(R.color.statusbar_bg);

Step 3:
Android: fitsSystemWindows = "true"
Android: clipToPadding = "false"

 

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.