【发布时间】:2019-09-24 12:58:48
【问题描述】:
我只是尝试使用带有 android 约束布局的组视图来更轻松地设置多个视图的可见性。问题是即使我将组的可见性更改为消失或不可见,它也不会做任何事情。
我已经尝试了 Pavan 在此线程中的响应步骤:toggle visibility of chain group in constraint layout。 但这对我没有任何改变。 (我假设是因为我没有使用测试版)
这是我的依赖应用程序 gradle 文件
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
这是我的 XML 文件与组的摘录
<Button
android:text="@string/action_update"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button_update"
android:layout_marginBottom="32dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp" android:layout_marginRight="8dp"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp" app:layout_constraintStart_toStartOf="parent" android:textSize="18sp"/>
<android.support.constraint.Group android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/group"
android:visibility="gone"
app:constraint_referenced_ids="button_update"/>
【问题讨论】:
标签: android kotlin android-constraintlayout