我正在尝试设置我为其制作的 border.xml 文件的边框,因为我使用了背景关键字来设置背景颜色,但添加背景关键字没有效果。谁能指导我如何设置边框内的背景颜色。这是我的 border.xml 代码:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="3dp"/>
<padding android:left="5dp" android:right="5dp" android:top="5dp" android:bottom="5dp"/>
<stroke android:width="5dp" android:color="#A5A5A5" android:background="#2B1B1B"/>
</shape>
最佳答案
您只需删除描边中的android:background="#2B1B1B"并添加属性solid,如下
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#2B1B1B"
<corners android:radius="3dp"/>
<padding android:left="5dp" android:right="5dp" android:top="5dp" android:bottom="5dp"/>
<stroke android:width="5dp" android:color="#A5A5A5"/>
</shape>
关于java - 如何在android studio中设置边框内的背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58279710/