Tom*_*m11 6 android android-layout android-constraintlayout
我想创建以下内容ConstraintLayout:
换句话说,我想要一个链,其中所有元素都展开,只有第二个和第三个元素被打包。我可以通过从链中删除第三个元素并将以下代码应用于它来做到这一点:
app:layout_constraintTop_toBottomOf="@+id/second_element"
它按预期工作。
但
在小型设备的情况下,此链被推到一起,第三个元素将在第四个元素上方。像这样:
在这种情况下,我需要将其均匀放置:
谢谢你的每一个帮助。
我通过将第二个和第三个项目提取到单独的布局来解决这个问题:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout ... >
<TextView
android:id="@+id/second"
app:layout_constraintTop_toTopOf="parent"
...
/>
<TextView
android:id="@+id/third"
app:layout_constraintTop_toBottomOf="@id/second"
...
/>
</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
并将其包含在主布局中。这包含的布局将取代第二个和第三个元素。通过将其添加到垂直链中,一切都按预期进行。
| 归档时间: |
|
| 查看次数: |
594 次 |
| 最近记录: |