Android边缘到边缘的渐变

时间:2018-10-18 14:45:47

标签: android android-layout

我正在尝试在矩形内部获得一个渐变,看起来像这样

enter image description here

使用以下xml最接近的是

enter image description here

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
    <gradient
        android:type="radial"
        android:startColor="@color/lightPurple"
        android:endColor="@color/lightGreen"
        android:gradientRadius="600"
        android:angle="270"
        android:centerX="1"
        android:centerY="0"/>

</shape>

我可以做些什么使渐变从右上角到左下角吗?

1 个答案:

答案 0 :(得分:1)

尝试android:type='linear'android:angle='45'

这将使您 更近 边缘到边缘。 Android 不为此提供任意角度。唯一有效的角度是45的倍数。但是,据我所知,您所需的渐变实际上并不是边缘到边缘的,我怀疑它是角度为45的渐变。

相关问题