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

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

问题描述

我要创建渐变背景的图片。但不能因为在centerColore呈S $ P $垫出覆盖底部和顶部。

我怎样才能让像下面的图片背景?或者我怎样才能让小ceterColor是不是S $ P $垫出来的?你有什么想法?

这是我想要的背景。

这是我犯的背景。

这是code的背景下按钮的XML上面

 <形状的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android机器人:形状=矩形>
    <梯度
        机器人:startColor =#6586F0
        机器人:centerColor =#D6D6D6
        机器人:endColor =#4B6CD6
        机器人:角=90/>
    <角落
        机器人:半径=0dp/>


< /形状>
 

解决方案

您可以通过使用XML <一个创建这个半梯度的样子href="http://developer.android.com/guide/topics/resources/drawable-resource.html#LayerList">Layer-List顶端和底部的条带合并成一个文件。每个波段是一个XML的形状。

有关详细的教程参见所以这previous答案:多梯度图形

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天全站免登陆