我想有一个像below图像一样的渐变。

我已经创建了这个形状,但即使尝试了这么多次,我也无法实现这种类型的渐变。任何帮助都将不胜感激。
这是我所做的工作:
<shape android:shape="rectangle">
<gradient
android:startColor="@color/red"
android:centerColor="@color/light_red"
android:endColor="@color/light_red"
android:angle="90"
/>
<corners
android:radius="20dp"
/>
</shape>发布于 2015-10-27 14:23:03
发布于 2020-07-30 03:57:02
你可以使用扫描渐变来解决这个问题!扫描渐变看起来像a bit like a cone,但是通过向左偏移(通过centerX),你可以用一个单一的渐变来达到效果。
下面是它的外观(忽略形状):

下面是XML:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="@android:color/red"
android:endColor="@android:color/holo_orange_dark"
android:centerX="-99"
android:type="sweep" />
<corners android:radius="20dp" />
</shape>https://stackoverflow.com/questions/33360702
复制相似问题