我使用带有偏见的约束布局来用多个视图填充屏幕。当我旋转视图时,它们不会调整大小以填充屏幕。我的布局更加复杂,但是我创建了一个示例来展示我的问题。
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/one"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@android:color/holo_orange_dark"
app:layout_constraintBottom_toTopOf="@+id/two"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:rotation="90"
android:background="@android:color/holo_green_light"/>
</FrameLayout>
<FrameLayout
android:id="@+id/two"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@android:color/holo_red_light"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/one">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_green_light" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
我旋转外部或内部FrameLayout并不重要。我不认为我在LinearLayouts上遇到过这个问题,也许旋转使约束变得混乱了吗?
编辑:嗯,当使用以重量为父级的Linearlayout时,发生的情况相同,因此Im可能在这里做错了。
[
Here是使用
translationY
的示例。查看顶部的“说明”部分。看到底视图从上到下受约束时,底视图如何不移动?那是因为它位于顶视图之前顶视图移动的位置。 translationY与rotation一样在布局后发生。可以(可能)只需少量编码即可解决此问题。确切的解决方案取决于您要执行的操作。