如何在android中使用3种颜色和141度进行渐变
我有以下css 背景:线性梯度(141deg,#0fb8ad 0%,#1fc8db 51%,#2cb5e8 75%) 我需要使用android实现前面的css 我尝试了下面的方法,但它给了我一个空的梯度如何在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
<?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”;只需使用默认值(线性)