Zai*_*far 20 android material-design
我一直在为Lollipop(API 21)开发一个应用程序.
当我将Button颜色更改为某些内容时,涟漪效果不起作用.
我找到了一些第三方库用于涟漪效应,但我想用标准API做到这一点.
这个答案也没有帮助.
XML:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"
android:layout_below="@+id/textView"
android:background="@android:color/holo_blue_bright"
android:layout_alignParentStart="true"
android:layout_marginTop="76dp"
/>
Run Code Online (Sandbox Code Playgroud)
Flo*_*ern 31
您必须将按钮的背景设置为RippleDrawable,您可以使用XML定义它.(我会说出来holo_blue_ripple.xml)
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@android:color/white"> <!-- ripple color -->
<item android:drawable="@android:color/holo_blue_bright"/> <!-- normal color -->
</ripple>
Run Code Online (Sandbox Code Playgroud)
然后用它来引用它android:background="@drawable/holo_blue_ripple".
kip*_*ip2 27
试试这个:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
...
/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20856 次 |
| 最近记录: |