简体   繁体   中英

Custom view on status bar

Facebook Messenger shows this view for a few seconds when resuming the app (it also hides the status bar icons). Does anyone know how to do this?

在此处输入图片说明

You will need to use the WindowInsets (SDK >= 20) to get the StatusBar's height. Create a FrameLayout, apply the LayoutParams(MATCH_PARENT, statusBarHeight) . Set the layout background color to colorPrimaryDark.

Hide de Status Bar by using the method setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN) .

To add the status text, create a LinearLayout, apply the LayoutParams(WRAP_CONTENT, MATCH_PARENT, Gravity.CENTER_HORIZONTAL) , Orientation = HORIZONTAL and add a Canvas and TextView.

Finally, add the LinearLayout as the child of the FrameLayout and add the FrameLayout as the first child of the main layout.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM