如何像这样在Android中创建径向渐变

时间:2019-03-19 09:39:34

标签: android radial-gradients android-shape

我想创建一个这样的渐变,但是:

左梯度是我的目标右梯度是我的目标 这是我的渐变代码xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
    android:centerColor="#ffffff"
    android:endColor="#4f4f4f"
    android:gradientRadius="700"
    android:startColor="#ffffff"
    android:type="radial" >
</gradient>

请帮助创建类似左侧图片的渐变

编辑: 在真实设备中,我的渐变显示为白色。 编辑2: 这些Gradient My Friend发表了,但目标Gradient中的颜色未在真实设备中显示 没有其他选择吗?

2 个答案:

答案 0 :(得分:0)

执行此操作:

   <?xml version="1.0" encoding="utf-8"?>
   <shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle" >
       <gradient
            android:centerColor="#E7E6E6"
            android:endColor="#DADADA"
            android:gradientRadius="800"
            android:startColor="#EEEDED"
            android:type="radial" >
       </gradient>
   </shape>

屏幕截图:

enter image description here

答案 1 :(得分:0)

这里是使用此工具的工具,您可以设计任何可绘制的Tool

尝试

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >
    <gradient
        android:type="linear"
        android:startColor="#FF2d7706"
        android:endColor="#FF98d434"
        android:angle="90"/>
</shape>

enter image description here