使用形状绘制为我的背景XML我的、形状、背景、XML

2023-09-05 10:15:53 作者:安心,安不下心°

我真的AP preciate,如果有人可以帮助我使用了如何使用形状绘制作为我的背景XML为我的看法。

I really appreciate if someone can help me with using how to use shape drawable as my background xml for my view.

这是我的尝试: 但我从来没有得到的颜色。机器人总是给我黑色文本白色背景上,我把不管什么颜色​​的属性。

This is what I tried: But I never get the color. Android always gives me black text on white background, regardless what color attribute I put.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle">
            <stroke android:width="1dip" android:color="#FBBB" />
            <solid android:color="#6000"/> 
</shape>

我试过了,也不行

I tried , does not work

<shape xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle"
            android:color="#6000>

</shape>

我试过了,也不行

I tried , does not work

<shape xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle"
            android:background="#6000>
</shape>

我谷歌,这是有限的结果,我发现去尝试。

I google this is the limited result I found to try.

推荐答案

您有错误的颜色设置,您必须指定4个字节的颜色,例如:#ffff8080

You have wrong color settings, you must specify 4 byte colors, eg: #ffff8080

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#f0600000"/>
    <stroke android:width="3dp" android:color="#ffff8080"/>
    <corners android:radius="3dp" />
    <padding android:left="10dp" android:top="10dp"
        android:right="10dp" android:bottom="10dp" />
</shape>