带有 TextView 边框的涟漪?
Ripples with border for a TextView?
我有几个 TextView
并排显示。目前,我使用 android:background="?attr/selectableItemBackground"
来获得触摸的涟漪。
现在,我想在未按下 TextView
时向它们添加边框,并在触摸 TextView
时产生波纹。我该怎么做?
Another way that we can confine the bounds of a ripple animation is to
actually define a shape drawable as a child
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:colorControlHighlight">
<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/white" />
<stroke
android:color="@color/card_set_bg_color"
android:width="1dp" />
</shape>
</item>
</ripple>
此处 <shape>
中的 <solid>
需要波纹渲染。如果设置为 transparent
或省略,则不会呈现涟漪。涟漪需要一个坚实的背景来渲染。 TextView
s 没有背景颜色,因此我们需要指定 <solid>
。
我有几个 TextView
并排显示。目前,我使用 android:background="?attr/selectableItemBackground"
来获得触摸的涟漪。
现在,我想在未按下 TextView
时向它们添加边框,并在触摸 TextView
时产生波纹。我该怎么做?
Another way that we can confine the bounds of a ripple animation is to actually define a shape drawable as a child
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:colorControlHighlight">
<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/white" />
<stroke
android:color="@color/card_set_bg_color"
android:width="1dp" />
</shape>
</item>
</ripple>
此处 <shape>
中的 <solid>
需要波纹渲染。如果设置为 transparent
或省略,则不会呈现涟漪。涟漪需要一个坚实的背景来渲染。 TextView
s 没有背景颜色,因此我们需要指定 <solid>
。