我有以下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>
发布于 2018-07-05 05:15:37
试试这个:
<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"
;只使用缺省值(线性)。
https://stackoverflow.com/questions/51180513
复制相似问题