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.