无法更改正在内部引用的单个视图的可见性约束布局组
使用 实现'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
尝试使用实现'androidx.constraintlayout:constraintlayout:1.1.3'(稳定版)但不起作用。
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true">
<View
android:id="@+id/bgView"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/full"
app:layout_constraintBottom_toTopOf="@id/bulletinsRV"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.github.mikephil.charting.charts.PieChart
android:id="@+id/chart"
android:layout_width="0dp"
android:layout_height="250dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:background="@color/white"
android:onClick="@{(v)->handler.onClickPieChart(v)}"
app:centerText="@{"Total Due:"+ vm.home.payment.totalAmount +" AED"}"
app:centerTextSize="@{vm.home.payment.paymentStatus.equals("FullyPaid")?0F:12F}"
app:description="@{vm.home.payment.paymentStatus.equals("FullyPaid")?``:"My payment"}"
app:dueCleared="@{vm.home.payment.paymentStatus.equals("FullyPaid")}"
app:goneWhen="@{vm.home.payment == null}"
app:isRotationEnabled="@{false}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:pieEntries="@{vm.pieEntries}"
app:touchEnabled="@{false}" />
<androidx.constraintlayout.widget.Group
android:id="@+id/group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:constraint_referenced_ids="bgView,chart"
app:visibleIf="@{vm.isUnitInitialized}" />
</androidx.constraintlayout.widget.ConstraintLayout>
默认的Constraint Helper类负责在组中设置视图的可见性,似乎正在将相同的值应用于组的所有子级,因此对于某些视图,您将无法单独覆盖它。想法似乎是,如果不是所有视图都共享相同的属性,则它们很可能不应该属于同一组。
这是默认帮助器中的相关代码: