Issue
Hello StackOverflowers.
I have a this layout:
<androidx.drawerlayout.widget.DrawerLayout
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:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
......
>
and it looks like this:
I just set the primary color alpha to 00 and the status bar has no color. What I like is that it goes full screen and under the status bar.
I made another activity, but it is a ConstraintLayout not as DrawerLayout as in the above case. I also set the android:fitsSystemWindows="true". but it just will not go full screen.
Here is the code:
<androidx.constraintlayout.widget.ConstraintLayout
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:id="@+id/splashScreenLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".SplashScreen">
<ImageView>
.......
<>
I could also use DrawerLayout to achieve this effect, but I do not need a drawer in that activity. Is there a more professional approach?
Solution
I found the answer. I had to set android:fitsSystemWindows="false" and I added this function to may activity and called it in on create:
private fun showSystemUI() {
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
}
Even the image view in my activity goes under the status bar. This is exactly what I wanted.
Answered By - Dinu Nicolae
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.