如何在android中使渐变背景 [英] How to make gradient background in android

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

问题描述

我想创建渐变背景,如图所示。但是不能因为centerColore被传播到底部和顶部。



我如何做下面的照片?或者如何制作不散开的小ceterColor?你有什么想法吗?



这是我想要的背景。





这是我做的背景。 >



这是上面的xml背景按钮代码

 < shape xmlns:android =http: //schemas.android.com/apk/res/androidandroid:shape =rectangle> 
< gradient
android:startColor =#6586F0
android:centerColor =#D6D6D6
android:endColor =#4B6CD6
android: = 90/>
< edges
android:radius =0dp/>


< / shape>


解决方案

您可以创建这个半渐变使用xml 图层列表,将顶部和底部的乐队组合成一个文件每个乐队都是一个xml形状。



有关详细的教程,请参阅SO上的以前的答案:多梯度形状


I want to create gradient background as in the picture. but it can't because of the centerColore was spread out to cover bottom and top.

How can I make a background like picture below? or How can I make small ceterColor that not spread out? did you have any idea?

This is the background that i want.

This is the background that I made.

This is code in xml of background button above

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
    <gradient 
        android:startColor="#6586F0"
        android:centerColor="#D6D6D6"
        android:endColor="#4B6CD6"
        android:angle="90"/>
    <corners 
        android:radius="0dp"/>


</shape>

解决方案

You can create this 'half-gradient' look by using an xml Layer-List to combine the top and bottom 'bands' into one file. Each band is an xml shape.

See this previous answer on SO for a detailed tutorial: Multi-gradient shapes.

这篇关于如何在android中使渐变背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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