在 Android 中的 ConstraintLayout 底部设置约束
Setting constrains at the bottom of the ConstraintLayout in Android
我想在 Android 中将 FrameLayout 的约束设置到导航栏的顶部。
这里是 XML 布局文件的代码:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
app:labelVisibilityMode="labeled"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorGreen"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/bottom_navigation"
app:itemIconTint="@color/colorPrimaryDark"
app:itemTextColor="@color/colorAccent"
/>
<FrameLayout
android:id="@+id/container_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation" />
</androidx.constraintlayout.widget.ConstraintLayout>
我试过这条线:
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation
但是生成的布局看起来不正确。在这里你可以看到一个截图:
你有什么想法我应该做什么?我会感谢每一条评论,并感谢你的帮助。
使用怎么样
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation"
app:layout_constraintTop_toTopOf="parent"
在您的框架布局中
我想在 Android 中将 FrameLayout 的约束设置到导航栏的顶部。
这里是 XML 布局文件的代码:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
app:labelVisibilityMode="labeled"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorGreen"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/bottom_navigation"
app:itemIconTint="@color/colorPrimaryDark"
app:itemTextColor="@color/colorAccent"
/>
<FrameLayout
android:id="@+id/container_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation" />
</androidx.constraintlayout.widget.ConstraintLayout>
我试过这条线:
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation
但是生成的布局看起来不正确。在这里你可以看到一个截图:
使用怎么样
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation"
app:layout_constraintTop_toTopOf="parent"
在您的框架布局中