Android 框架布局不';不适合它的空间
我是第一次使用NavigationBar小部件,我无法将FrameLayout设置为不在NavigationBar后面。 我真的尝试了一切:在RelativeLayout(导航栏消失)中设置这两种设置,在StackOverflow中找到的每种设置,但都没有成功 这是我的密码:Android 框架布局不';不适合它的空间,android,xml,android-fragments,fragment,Android,Xml,Android Fragments,Fragment,我是第一次使用NavigationBar小部件,我无法将FrameLayout设置为不在NavigationBar后面。 我真的尝试了一切:在RelativeLayout(导航栏消失)中设置这两种设置,在StackOverflow中找到的每种设置,但都没有成功 这是我的密码: <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android=
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="mypackage.myActivity"
android:background="@color/background_activities">
<FrameLayout
android:id="@+id/frame_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
app:layout_constraintTop_toTopOf="parent"
android:fitsSystemWindows="true"
>
</FrameLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/color_NavigationBar"
app:itemIconTint="@color/white"
app:itemTextColor="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/navigation" />
</android.support.constraint.ConstraintLayout>
尝试此操作,将框架布局约束设置为完全剪裁到父级,将底部剪裁到导航顶部除外,然后将高度和宽度设置为0dp,以便它可以根据约束进行增长:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="mypackage.myActivity"
android:background="@color/background_activities">
<FrameLayout
android:id="@+id/frame_layout"
android:layout_width="0dp"
android:layout_height="0dp"
android:animateLayoutChanges="true"
app:layout_constraintBottom_toTopOf="@+id/navigation"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"></FrameLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/color_NavigationBar"
app:itemIconTint="@color/white"
app:itemTextColor="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/navigation" />
</android.support.constraint.ConstraintLayout>
根据您的建议,它可以工作,但现在导航栏在单击时开始“更改高度”,我用图片更新了第一个psot。请您再帮我一次好吗?我看不到图片:/尝试将导航的高度更改为android:layout\u height=“wrap\u content”