繁体   English   中英

如何更改按钮 XML-AndroidStudio 上的背景?

[英]How do i change the background on the buttons XML-AndroidStudio?

我正在 Android Studio 中开发一个小应用程序,但我无法更改按钮颜色。 我已经尝试了一切,只改变背景,backgroundtint,来制作一个新的可绘制对象,但我似乎找不到任何答案,这是我的按钮 XML 布局:

<Button
    android:id="@+id/calc"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="55dp"
    android:layout_marginTop="45dp"
    android:background="@drawable/round_green_shape"
    android:text="CALCULA">
</Button>

这是我背景的 XML:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    android:padding = "10dp">

<solid android:color="@color/buttonsGreen">
</solid>

<corners
    android:radius="15dp">
</corners>
</shape>

但这就是我的按钮的样子: 在此处输入图像描述

在应用程序上它们看起来是一样的: 在此处输入图像描述

我将不胜感激任何帮助,

谢谢

完成,我只需要删除

android:background = ""

并设置:

android:backgroundTint = ""

变绿...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM