首页 > 解决方案 > 如何在 constraint.Group 中设置涟漪 (android:foreground="?selectableItemBackground")

问题描述

我的item_layoutcontraint.Group里面有一个,我将在recyclerView中使用它:

<android.support.constraint.Group
        android:id="@+id/constraintGroup"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:constraint_referenced_ids="imageView, textView" />

我还在完美运行的活动中为该组设置了onClickListener 。问题是每次我点击该组时,都不存在连锁反应。

任何人都知道我应该怎么做才能在constraint.Group中产生这种效果?

我尝试将属性添加android:foreground="?selectableItemBackground"到父级和约束。组但它不起作用:(

标签: androidandroid-layoutkotlin

解决方案


AGroup仅用于控制可见性。您无法控制组成员的任意 UI 属性,例如背景。相反,您需要将背景放在实际的小部件上。


推荐阅读