Reputation: 3602
I constrain a button to the bottom of the screen, but unfortunately there is a small gap between the bottom border of the screen and the bottom border of the buttom:
My XML:
<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=".MainActivity">
<com.google.android.material.tabs.TabLayout
android:id="@+id/navigationTabs"
android:layout_width="match_parent"
android:layout_height="100dp"
app:layout_constraintTop_toTopOf="parent"
app:tabMinWidth="100dp"
app:tabRippleColor="@null"
/>
<Button
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="BUTTON"
android:layout_margin="0dp"
app:layout_constraintBottom_toBottomOf="parent"/>
<LinearLayout
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/navigationTabs" />
</androidx.constraintlayout.widget.ConstraintLayout>
What causes this gap? And how can I get rid of it?
Upvotes: 3
Views: 7827
Reputation: 70
add this code to <androidx.constraintlayout.widget.ConstraintLayout ...>
and <button ...>
:
android:layout_margin="0dp"
android:padding="0dp"
add this code to <com.google.android.material.tabs.TabLayout ...>
and <LinearLayout ...>
and <button ...>
:
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
add this code to <button ...>
:
android:background="#c0c0c0"
Upvotes: 1
Reputation: 2385
It's the shadow around the button of the default background. Specify your own background and the gap will disappear. For example:
<Button
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#A4ABA4"
android:text="BUTTON"
android:layout_margin="0dp"
app:layout_constraintBottom_toBottomOf="parent"/>
Upvotes: 7