码迷,mamicode.com
首页 > 移动开发 > 详细

android渐变效果

时间:2015-09-29 21:54:55      阅读:317      评论:0      收藏:0      [点我收藏+]

标签:

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:orientation="vertical">
<TextView android:layout_width="fill_parent" android:layout_height="500px"
android:text="Hello World!" android:background="@drawable/bg_border
"
android:textColor="#ffffff"/>
</LinearLayout>

drawable文件下建立bg_border.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 指定圆角矩形的4个圆角的半径 -->
<corners android:topLeftRadius="20px"
android:topRightRadius="5px"
android:bottomRightRadius="20px"
android:bottomLeftRadius="5px"/>
<!-- 指定边框线条的宽度和颜色 -->
<stroke android:width="4px" android:color="#f0f" />
<!-- 指定使用渐变背景色,使用sweep类型的渐变
颜色从红色→绿色→蓝色 -->
<gradient android:startColor="#f00"
android:centerColor="#0f0"
android:endColor="#00f"
android:angle="270"
android:centerX="0.5"
android:centerY="0.5"
/>
<!--angle的值:从左到右为0;然后逆时针旋转,90度为从下到上,270为从上到下。
centerx和centery的值取0-1;表示中间色的位置,中间色分别是0,0.5,1。中间色为0的,则渐变的中间色的位置在最上面;中间色为0.5的,则渐变的中间色在屏幕中间;中间色为1 的,则中间色在屏幕下部。-->
</shape>
运行结果:

技术分享

<gradient android:startColor="#f00"
android:centerColor="#0f0"
android:endColor="#00f"
android:angle="90"
android:centerX="0.5"
android:centerY="0.5"
/>

技术分享

android渐变效果

标签:

原文地址:http://www.cnblogs.com/bingningran/p/4847288.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!