【发布时间】:2021-12-11 01:43:12
【问题描述】:
以前,我使用StateDrawable 来实现带有阴影效果的自定义卡片视图 - https://stackoverflow.com/a/33829309/72437。这是由于CardView 的限制,无法在其cardBackgroundColor 中接受选择器
现在,我想添加涟漪效果。我使用以下 XML。
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#00ff00">
<item android:drawable="@drawable/statelist_item_background"/>
</ripple>
但是,这会产生副作用,绿色波纹会一直延伸到阴影区域。
我想避免绿色波纹接触阴影区域。我尝试添加填充信息。
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#00ff00">
<item>
<shape android:shape="rectangle">
<padding android:top="10dp" android:right="10dp" android:bottom="10dp" android:left="10dp" />
</shape>
</item>
<item android:drawable="@drawable/statelist_item_background"/>
</ripple>
但是,这并没有什么不同。在ripple 标签内添加填充信息没有区别。
我可以知道如何填充波纹效果吗?
【问题讨论】:
-
使用 layout_margin。涟漪效应不会超出您的利润范围
-
你有解决办法吗?
标签: android