Cha*_*ere 7 android checkedtextview android-5.0-lollipop android-recyclerview
在Android 5.0 Lollipop上运行时,我对使用CheckedTextViews的RecyclerView感到沮丧.棒棒糖之前的所有版本都很好,并没有出现这个问题.请查看下面的图片以便更好地理解:


了解Lollipop如何仅在CheckedTextView的复选框部分上绘制选择突出显示?Pre-Lollipop没有此问题/ bug,并在视图的整个宽度上绘制选择突出显示(这是我想要的行为).
这是我正在绘制到列表中的CheckedTextView:
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:background="?attr/selectableItemBackground"
android:checkMark="@drawable/checkbox"
android:id="@+id/model_checkable_name"
android:layout_height="48dp"
android:layout_width="match_parent" />
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?我已经尝试了各种不同的解决方案,如极少数android:focusable="false",android:duplicateParentState="true",android:duplicateParentState="false"...
多谢你们!
您可以像在 Google IO 应用程序中一样使用 CheckBoxPreference 来解决此问题,顺便说一句,我想知道 CheckedTextView 中是否存在 Lollipop 问题。
我尝试使用backgroundselectablebordeless,但它也不起作用。
你解决了它还是一个已知的错误?
编辑:
您可以在checktextview上使用framelayout,并使用onClickListener和framelayout来设置checktextview的选中和未选中状态。将framelayout和checkedtextview放在相对布局中:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:layout_marginTop="8dp"
android:background="@color/md_divider" />
<android.support.v7.widget.SwitchCompat
android:id="@+id/switchWidget"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:padding="16dp"
android:text="Switch Widget Title"
android:textAppearance="@style/TextAppearance.AppCompat.Inverse"
android:textColor="@color/md_text"
android:textSize="16sp" />
<FrameLayout
android:id="@+id/frameLayoutSwitch"
android:clickable="true"
android:background="?attr/selectableItemBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
692 次 |
| 最近记录: |