约束布局绘制顺序/图层顺序



简单的问题:

约束布局使用的确切算法是什么,以便知道哪个视图先绘制,哪个视图最后绘制?

在 RelativeLayout 中,XML 文件中的最后一个视图是最后绘制的,因此它将位于所有视图的顶部,从而掩盖了之前绘制的视图。

为什么 ConstraintLayout 不携带相同的功能(至少显然)?

以下代码导致按钮显示在包含的视图的顶部。

<Button
android:id="@+id/calculate"
android:layout_width="183dp"
android:layout_height="76dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:text="C A L C U L A T E"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent" />
<include
android:id="@+id/help_window"
layout="@layout/help_window"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="0dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/include4" />

</android.support.constraint.ConstraintLayout>

好吧。我现在解决了这个问题。

显然,按钮是分开处理的。在海拔高度上始终位于顶部。

解决方案是删除此提升,将其写入按钮的XML文件中:

android:stateListAnimator="@null">

最新更新