当触摸布局时,如何在简单的线性/相对布局中产生连锁反应?
我尝试将布局的背景设置为类似以下内容:
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:colorControlHighlight" >
<item android:drawable="@android:color/white"/>
</ripple>
然而,当我触摸布局时,我只看到一个普通的白色背景,没有波纹效果。我做错了什么?
编辑:
作为参考,下面是我的布局xml文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="250dp"
android:layout_height="250dp"
android:background="@drawable/test"
android:clickable="true">
</RelativeLayout>
发布于 2014-11-20 23:56:38
事实证明,这是预期的工作。标准材质主题colorControlHighlight值为#40ffffff
。因此,在白色背景上,这将不会显示。将突出显示颜色更改为其他颜色,和/或更改对象的背景颜色。
感谢所有人(特别是Alanv为我指明了正确的方向)。
发布于 2019-02-11 18:55:51
以下是单击具有涟漪效果的样例布局的示例:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:orientation="vertical">
发布于 2014-11-19 18:11:22
在布局上设置android:clickable="true"
。
https://stackoverflow.com/questions/27006288
复制相似问题