【发布时间】:2020-05-24 18:58:06
【问题描述】:
我将一个按钮约束在屏幕底部,可惜屏幕底部边框和按钮底部边框之间有一个小间隙:
我的 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>
造成这种差距的原因是什么?我怎样才能摆脱它?
【问题讨论】:
-
android studio 有一个名为“layout inspect”的功能。您可以在工具选项下找到它。您可以使用此功能检查布局以检查导致间隙的原因!希望有帮助!
标签: android android-constraintlayout android-button