Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了创建图标按钮 – Android大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想创建一个小图标按钮,如 in this chapter of the material guideline所述,但我找不到任何解释如何做到这一点.

这是我要转换为图标切换的按钮:

<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以改为使用图标?

解决方法

drawable_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- Put your color for ripple effect -->
<ripple xmlns:android="http://scheR_866_11845@as.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"

阅读这个关于RippleDrawable它已经有选择器了.

大佬总结

以上是大佬教程为你收集整理的创建图标按钮 – Android全部内容,希望文章能够帮你解决创建图标按钮 – Android所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。