如何获得android渐变中心光效果? [英] how to get android gradient center light effect?

查看:500
本文介绍了如何获得android渐变中心光效果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要类似下面的图片

我尝试使用可绘制形状

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
    android:angle="360"
    android:centerX="50%"
    android:centerY="50%"

    android:gradientRadius="50%"
    android:endColor="#000000"
    android:centerColor="#FFFFFF"
    android:startColor="#000000" >
</gradient>
</shape> 

推荐答案

在可绘制文件夹中新建一个Android xml文件(例如GreyRadial.xml)

Make a new Android xml file (say GreyRadial.xml) file in your drawable folder

在您的xml文件中

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <gradient
        android:centerColor="#c1c1c1"
        android:endColor="#4f4f4f"
        android:gradientRadius="400"
        android:startColor="#c1c1c1"
        android:type="radial" >
    </gradient>

</shape>

使用

在您的布局背景中使用此xml

Use this xml in your layout background using

android:background="@drawable/GreyRadial"

这篇关于如何获得android渐变中心光效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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