我正在使用Android Studio 3.6来构建新项目“底部导航活动”。
activity_main.xml中的片段容器具有约束:app:layout_constraintBottom_toTopOf="@id/nav_view"
我期望片段的底部现在在导航视图上方。
但是当我在fragment_home.xml中添加按钮时:
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="35dp"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
按钮与导航栏重叠(已经添加了底部的边距):
我的误会在哪里?如何使片段的底部位于navBar上方?
您的片段容器layout_height
的activity_main.xml
是否设置为match_parent
?
如果是,则将其设置为0dp
(匹配约束)。