In Android Studio Koala, The mobile app runs up to the status bar. To make the app run below the status bar instead, how can I do that?
When an application run Like image 1, some button can’t be touched.
So, like image 2, enter image description hereI want to run an application below the status bar like before.
How can I do write code xml or java?
1
In Koala IDE, When you create a activity and it gives a extra code
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_tede)
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}
}
And to fix the status bar issue, You need to remove extra code to make it work as below
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_tede)
}
hi i don’t know about your code but in first image you are using
decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
so know you can remove this line your problem should be solved
Add attributes to the root layout node: android:fitsSystemWindows="true"
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="#FFFFFF">
.....
</androidx.constraintlayout.widget.ConstraintLayout>