如何控制上的形状的梯度? [英] How to control the gradient on a shape?

查看:145
本文介绍了如何控制上的形状的梯度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在顶部的标签的屏幕。此标签做用一个TextView。 作为一个背景,我想有一个垂直梯度,从颜色1,更改为COLOR2再换颜色1。 目前,我有:

I have a screen with a label on top. This label is done with a TextView. As a background I'd like to have a vertical gradient, starting with color1, changing to color2 and back to color1. At the moment I have:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <stroke android:width="1px" android:color="#000000" /> 
    <gradient
        android:startColor="#FFFFFFFF"
        android:centerColor="#FF8800"
        android:endColor="#FFFFFFFF" 
        android:type="linear"
        android:angle="270" 
/>
    <corners android:radius="10dp"/>
</shape>

我的问题是,centerColor线太薄。我希望它按观测所有的字母空间。 我找不到任何方法,使梯度更快。 我已经尝试过使用布局名单,但没有成功。

My problem is that the centerColor line is too thin. I want it to ocupy all the letters space. I can't find any way to make the gradient to be faster. I've already tried to use a layout-list but with no success.

你知道吗?

推荐答案

这是一个更加不同的轨道跟随,但是你有没有考虑与9补丁图像文件的工作?这将允许你伸展渐变的,你要的部分,并根据需要通过适当地分割了背景使中心线为大。

This is a much more different track to follow but have you considered working with 9-patch image files? This will allow you to stretch the parts of the gradient that you wish to and make the centre line as big as needed by segmenting up the background properly.

下面是一些伟大的教程我已经习惯了了解他们: 得出9补丁教程

Here are some great tutorials I have used to learn about them: draw 9 patch tutorial

和来自谷歌的自己的Andr​​oid嘴: Android的9补丁 为Android 的所有可绘制资源

And from Google's own Android mouth: Android 9 patch All Drawable resources for Android

这篇关于如何控制上的形状的梯度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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