ConstraintLayout doneMargin居中于边缘时不起作用

问题描述 投票:0回答:1

enter image description here

对于我在下面的XML中声明的上述布局,当view_212dp时,我试图使view_1的起始边距默认为GONE。想知道如何使用goneMargin*实现它吗?当我有约束时,将app:layout_goneMarginStart="12dp"设置为view_2无效,就像我将小部件平均拉开的相反力(I am referring to this approach of positioning)]

    <View
        android:id="@+id/view_1"
        android:background="@color/faded_green"
        android:layout_width="100dp"
        android:layout_height="100dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">
    </View>
    <View
        android:id="@+id/view_2"
        android:background="@color/deep_red"
        android:layout_width="100dp"
        android:layout_height="50dp"
        app:layout_constraintStart_toEndOf="@id/view_1"
        app:layout_constraintEnd_toEndOf="@id/view_1"
        app:layout_constraintTop_toTopOf="@id/view_1"
        app:layout_constraintBottom_toBottomOf="@id/view_1">
    </View>

对于我在下面的XML中声明的上述布局,当view_1为GONE时,我试图使view_2的起始边距默认为12dp。想知道如何使用godMargin *实现它吗? ...

android android-layout android-constraintlayout
1个回答
0
投票

您将必须以编程方式删除view_2

© www.soinside.com 2019 - 2024. All rights reserved.