首页 > 解决方案 > 更改具有透明背景的圆形按钮的颜色

问题描述

如何更改圆角文本视图或具有透明背景的按钮的颜色,像这样图片

我希望再次单击按钮时取消选择,而不仅仅是选择

标签: androidmaterial-designandroid-buttonmaterial-components-androidandroid-chips

解决方案


在可绘制文件夹 bg.xml 中添加 xml 文件

 <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" android:padding="10dp">
    <!-- you can use any color you want I used here gray color-->
    <stroke
        android:height="1.0dip"
        android:width="1.0dip"
        android:color="#ffee82ee" />

    <solid android:color="@android:color/transparent"/>
    <corners android:radius="7dp"/>
</shape>

并在布局

   <Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/bg"
    android:textColor="#ffee82ee"/>

它会工作..


推荐阅读