【发布时间】:2019-01-30 17:53:33
【问题描述】:
以下布局中的复选框有显示问题。当我尝试选中或取消选中它们时,我得到了这种结果: 有时,我得到一个灰色或一个非常小的复选标记。 此外,如果我在多次单击它后设法选中一个,如果我单击另一个,它将再次播放第一个复选框的动画。在这种情况下,所有复选框看起来都像“链接”。
我删除了两个animateLayoutChanges,但它并没有改变任何东西。
我删除了scrollView,但没有结果。
我还在 Android 28 和 23 上测试了这个布局,但它不仅适用于 API 23。
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".NewOpeningHourActivity"
android:animateLayoutChanges="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar_new_opening_hour"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.PopupOverlay"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_new_opening_hour"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_weight="1"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<ScrollView
android:id="@+id/scroll_new_opening_hour"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/appbar_new_opening_hour"
app:layout_constraintVertical_bias="0.0">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="@+id/cv_new_opening_hour"
style="@style/CardFoldAppearance"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:animateLayoutChanges="true"
android:padding="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.constraint.ConstraintLayout
android:id="@+id/ctl_new_opening_hour"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<TextView
android:id="@+id/tv_new_opening_hour_title_days"
style="@style/boldMTextAppearance"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:text="@string/new_openhours_card_days_title"
app:layout_constraintEnd_toStartOf="@+id/imagebtn_new_opening_hour_days_fold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/imagebtn_new_opening_hour_days_fold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:contentDescription="Fold or unfold days list"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_round_keyboard_arrow_up_24px" />
<CheckBox
android:id="@+id/cbx_new_opening_hour_day_monday"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/day_monday"
app:layout_constraintTop_toBottomOf="@+id/tv_new_opening_hour_title_days" />
<CheckBox
android:id="@+id/cbx_new_opening_hour_day_tuesday"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/day_tuesday"
app:layout_constraintTop_toBottomOf="@+id/cbx_new_opening_hour_day_monday" />
<CheckBox
android:id="@+id/cbx_new_opening_hour_day_wednesday"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/day_wednesday"
app:layout_constraintTop_toBottomOf="@+id/cbx_new_opening_hour_day_tuesday" />
<CheckBox
android:id="@+id/cbx_new_opening_hour_day_thursday"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/day_thursday"
app:layout_constraintTop_toBottomOf="@+id/cbx_new_opening_hour_day_wednesday" />
<CheckBox
android:id="@+id/cbx_new_opening_hour_day_friday"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/day_friday"
app:layout_constraintTop_toBottomOf="@+id/cbx_new_opening_hour_day_thursday" />
<CheckBox
android:id="@+id/cbx_new_opening_hour_day_saturday"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/day_saturday"
app:layout_constraintTop_toBottomOf="@+id/cbx_new_opening_hour_day_friday" />
<CheckBox
android:id="@+id/cbx_new_opening_hour_day_sunday"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/day_sunday"
app:layout_constraintTop_toBottomOf="@+id/cbx_new_opening_hour_day_saturday" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
</android.support.constraint.ConstraintLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
我的依赖:
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-rc01'
implementation 'com.android.support:support-v4:28.0.0-rc01'
implementation 'com.android.support:design:28.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
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'
}
【问题讨论】:
-
使用
android:buttonTint="@color/blue" -
你为复选框使用了自定义动画吗?
-
@HemantParmar 除了盒子的边框之外什么都没有改变
-
@fanjavaid 不,甚至没有自定义样式
-
已解决
rc02。