问题描述
layout (default)
/w320dp
/w360dp
/w450dp
/w700dp
我想实现一个两窗格布局,但有一个我没有预料到的奇怪行为。假设我有一个由 2 FragmentContainerView
组成的布局 sw450land dp。所以横向屏幕宽度是 700dp。
由于宽度是700dp,我认为每个Container都会加载一个w320dp的布局版本。但相反,每个 Container 加载一个布局版本 w700dp。
所以我想知道这是否是正常行为?如果是这样,为什么fragment的布局大小没有调整到容器的大小?
<?xml version="1.0" encoding="utf-8"?>
<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=".DualModeActivity">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/fragment_container_01"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="@color/yellow_light"
android:name="com.example.mytestapplicationnew.DualModeFragment"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/fragment_container_02"
/>
<androidx.fragment.app.FragmentContainerView
android:id="@+id/fragment_container_02"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="@color/blue_light"
android:name="com.example.mytestapplicationnew.DualModeFragment"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toEndOf="@id/fragment_container_01"
app:layout_constraintEnd_toEndOf="parent"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="sw 450 land"
android:textSize="30sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)