有一种叫做Widget.Material.Button
的风格,它具有我非常喜欢的动画效果(它会让点击产生“飞溅”),我希望能够在代码中重用它。我该如何模仿棒棒糖(Material Design)按钮动画?
我试图让它具有透明背景色,因为它默认为灰色,在应用于我的ViewGroup
对象时看起来不太好。
有没有简单的方法来保持动画,但摆脱背景颜色?
我已经尝试设置属性android:background="@android:color/transparent"
,但这会导致动画完全停止工作。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@android:style/Widget.Material.Button"
tools:targetApi="lollipop">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, world!"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is just another line of text."/>
</LinearLayout>
完美,所提供的链接也很丰富。 – zxgear