我想创建一个小图标按钮,如下所述在材料指南的这一章中 https://www.google.com/design/spec/components/buttons.html#buttons-other-buttons,但我找不到任何关于如何做到这一点的解释。
这是我想要转换为图标切换的按钮:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_row="4"
android:layout_column="0"
android:id="@+id/btn_delete"
android:drawableStart="@drawable/ic_delete"
android:drawableLeft="@drawable/ic_delete"
style="?android:attr/borderlessButtonStyle"/>
如何更改我的 xml 以具有图标?
可绘制_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- Put your color for ripple effect -->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@android:color/holo_green_dark">
<item android:id="@android:id/mask">
<shape android:shape="oval" >
<!-- Color not displayed,just to tell ripple about the bounds -->
<solid android:color="@android:color/black" />
</shape>
</item>
<!-- And your drawable -->
<item android:drawable="@drawable/btn_star_off_normal_holo_dark" />
</ripple>
使用它作为按钮的背景
android:background="@drawable/drawable_bg"
并阅读有关波纹绘制 https://developer.android.com/reference/android/graphics/drawable/RippleDrawable.html它已经有选择器了。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)