在Android的圆形渐变 [英] Circular gradient in android

查看:441
本文介绍了在Android的圆形渐变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

林试图使梯度发射从白色屏幕的中部,并变为黑色,因为它移向屏幕的边缘。

Im trying to make a gradient that emits from the middle of the screen in white, and turns to black as it moves toward the edges of the screen.

正如我做一个正常的梯度这个样子,我一直在尝试不同的形状:

As I make a "normal" gradient like this, I have been experimenting with different shapes:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient android:startColor="#E9E9E9" android:endColor="#D4D4D4"
        android:angle="270"/>
</shape>

在使用椭圆形字形我至少得到了一个圆形,但没有渐变的效果。我怎样才能做到这一点?

When using the "oval"-shape I at least got a round shape, but there were no gradient effect. How can I achieve this?

干杯,

推荐答案

您可以用得到一个圆形的渐变机器人:TYPE =放射状

You can get a circular gradient using android:type="radial":

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient android:type="radial" android:gradientRadius="250"
        android:startColor="#E9E9E9" android:endColor="#D4D4D4" />
</shape>

这篇关于在Android的圆形渐变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆