Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android中使用3种颜色和141度进行渐变_Android_Xml - Fatal编程技术网

如何在android中使用3种颜色和141度进行渐变

如何在android中使用3种颜色和141度进行渐变,android,xml,Android,Xml,我有以下css 背景:线性梯度(141deg,#0fb8ad 0%,#1fc8db 51%,#2cb5e8 75%) 我需要使用android实现前面的css 我尝试了下面的方法,但它给了我一个空的梯度 <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item> &l

我有以下css 背景:线性梯度(141deg,#0fb8ad 0%,#1fc8db 51%,#2cb5e8 75%)

我需要使用android实现前面的css

我尝试了下面的方法,但它给了我一个空的梯度

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape>
            <gradient
                android:angle="90"
                android:startColor="#0fb8ad"
                android:endColor="#2cb5e8"
                android:centerColor="#1fc8db"
                android:type="radial" />
        </shape>
    </item>
</selector>

试试这个:

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

    <gradient
        android:angle="135"
        android:startColor="#000fb8ad"
        android:endColor="#802cb5e8"
        android:centerColor="#c01fc8db"/>

</shape>

我使用alpha通道来模拟原始的百分比:
00
为0%,
80
为50%,而
C0
为75%

在Android中,渐变角度必须是45度的倍数,所以我用135度代替141度

不要指定android:type=“radial”;只需使用默认值(线性)