How to add a ripple effect on a layout with rounded corners? [duplicate]

╄→гoц情女王★ 提交于 2019-12-14 00:54:58

问题


I want to set a ripple effect on layout with rounded corners. How can I do it?


回答1:


Use Following code.

<?xml version="1.0" encoding="utf-8"?>
<ripple android:color="@color/COLOR_WHILE_PRESSING" xmlns:android="http://schemas.android.com/apk/res/android">
 <item android:drawable="@drawable/round_corner"></item>
</ripple>

round_corner.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
 <solid android:color="@color/BACKGROUND_COLOR" />
 <corners android:radius="6dp" />
</shape>



回答2:


just set these properties in xml file

android:background="?android:attr/selectableItemBackground"
android:clickable="true"

That should do it.



来源:https://stackoverflow.com/questions/42483072/how-to-add-a-ripple-effect-on-a-layout-with-rounded-corners

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!