How do I get rid of this tiny black space under the bottom "gesture bar"? Most apps extend all the way to the bottom, but I still see this tiny black bar on the bottom.
Main Activity XML
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.MainActivity">
<androidx.fragment.app.FragmentContainerView
android:id="@ id/fragmentContainerView"
android:name="com.myProject.fragments.SignUpFragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout="@layout/sign_up_fragment" />
</androidx.constraintlayout.widget.ConstraintLayout>
CodePudding user response:
As I know you can't remove this bar but you can make that transparent
here a little hack of code
this.window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
as this will make your screen full and a transparent its a little hack but you can try this
here what above code does make your screen full screen and the gesture will be transparent an you will get your desire output
CodePudding user response:
How do I get rid of this tiny black space under the bottom "gesture bar"?
To extend the app to the most bottom, you need to make your app full screen with:
WindowCompat.setDecorFitsSystemWindows(window, false)
But this also draws the app over the top status bar; to avoid that you need to handle overlaps using insets by registering OnApplyWindowInsetsListener
:
First give your root layout ConstraintLayout
an id, say root
:
val root = findViewById<ConstraintLayout>(R.id.root)
val onApplyWindowInsetsListener =
OnApplyWindowInsetsListener { view: View, windowInsets: WindowInsetsCompat ->
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
// Apply the insets as a margin to the root view in order to set the layout drawing area
view.layoutParams = (view.layoutParams as FrameLayout.LayoutParams).apply {
topMargin = insets.top // to draw below the top status bar
leftMargin = insets.left
rightMargin = insets.right
}
// Return CONSUMED if you don't want want the window insets to keep being
// passed down to descendant views.
WindowInsetsCompat.CONSUMED
}
ViewCompat.setOnApplyWindowInsetsListener(root, onApplyWindowInsetsListener)
Now you need to hide the bottom navigation bar, and enable showing it whenever the user swipes up from the bottom:
WindowInsetsControllerCompat(window, window.decorView).apply {
hide(WindowInsetsCompat.Type.navigationBars())
systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
}
This is working starting from API level 21.