我想在我的ImageView中添加波纹:
API +21
API -21(可选):
我尝试过:
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/google_blue200">
<item>
<shape android:shape="oval">
<solid android:color="@color/google_red200"/>
</shape>
</item>
</ripple>
但是,我希望主题可以选择波纹颜色 我希望圆形蒙版透明(没有波纹时)。
我尝试过:
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?attr/MyRippleColor">
<item android:id="@android:id/mask">
<shape android:shape="oval">
<solid android:color="?attr/backgroundColor"/>
</shape>
</item>
</ripple>
但是我看不到涟漪。
答案 0 :(得分:0)
此xml帮助我了解什么是遮罩,背景项目:
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/myColor">
<!-- Use this to define the shape of the ripple effect (rectangle, oval, ring or line). The color specified here isn't used anyway -->
<item android:id="@android:id/mask">
<shape android:shape="ring">
<corners android:radius="3dp"/>
<!-- This color is needed to be set - doesn't affect anything -->
<solid android:color="@android:color/white"/>
</shape>
</item>
</ripple>