我有两种设置波纹自定义颜色的方法:
1)
android:background="?attr/selectableItemBackground"
android:theme="@style/Theme.DayNight"
和
<item name="colorControlHighlight">@color/my_color</item>
2)
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="oval">
<solid android:color="@color/google_grey200_alpha_10"/>
</shape>
</item>
<item android:state_focused="true">
<shape android:shape="oval">
<solid android:color="@color/google_grey200_alpha_12"/>
</shape>
</item>
<item android:state_hovered="true">
<shape android:shape="oval">
<solid android:color="@color/google_grey200_alpha_4"/>
</shape>
</item>
</selector>
并将此可绘制选择器设置为android:background
。
即使它没有为android:state_focused
和android:state_hovered
定义颜色,它还是更干净,更推荐的第一方法吗?
物质波纹只是忽略了这些状态?