如何使用Android GradientDrawable [英] How to use Android GradientDrawable

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

问题描述

我尝试使用GradientDrawable为某些背景和按钮设置渐变. 遗憾的是,文档并不是很详细.

I try to use the GradientDrawable to set a gradient to some backgrounds and buttons. Sadly the documentation is not very detailed.

配置渐变的主要属性是什么?我了解start和endcolor,但其他一些属性可能需要一些解释.

What are the main attributes to configure the gradient? I understand start and endcolor but some of the other attributes could need some explanation.

此刻,我使用图像作为按钮的背景,但是用XML定义的可绘制对象会更好.

At the moment I used images as the background for the buttons but a drawable defined in XML would be much nicer.

我尝试看起来像这样(渐变非常浅):替代文字http://janusz.de/~janusz/RedButton.png

I try to get a look like this (It is a very light gradient): alt text http://janusz.de/~janusz/RedButton.png

推荐答案

使用此xml作为imageview的背景.

use this xml as background to the imageview.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:angle="90" android:startColor="#7c0000" android:endColor="#A71C1C"/>
</shape>

就这样.

这篇关于如何使用Android GradientDrawable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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