Android开发 设置颜色渐变

来源:互联网 发布:淘宝大促活动有哪些 编辑:程序博客网 时间:2024/06/04 23:29

给背景设置渐变色:

1.在res/drawable目录下建立xml文件,如background_text.xml:
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android">     <gradient          android:startColor = "#CC99FF"     android:endColor = "#0099FF"     android:centerColor="#00ffff"     android:angle = "90"/></shape>
解释:
  startColor标签表示开始时的颜色;
  endColor标签表示结束时的颜色;
  centerColor标签表示中间颜色;
  angle表示渐变的方向;
使用方法:通常可以在布局文件中的background标签中引用:@drawable/background_text.xml;
           
原创粉丝点击