修改Android主题里Button的默认背景颜色

576 阅读1分钟

修改Android主题里Button的默认背景颜色

先用这个试试

android:backgroundTint="@null"

去不掉的话用下面这个

app:backgroundTint="@null"

会提示错误:命名空间 'app' 未绑定 

在根布局的属性里加

xmlns:app="http://schemas.android.com/apk/res-auto"

然后再添加按钮背景就可以看到效果了

android:background="#55AA5577"

完整代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:padding="20dp">
 
    <Button
        android:id="@+id/btnConfirm"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:layout_marginTop="40dp"
        app:backgroundTint="@null"
        android:background="#55AA5577"
        android:text="按钮" />
</LinearLayout>