android 背景边框变圆角

<?xml version="1.0" encoding="utf-8"?>

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

 <stroke android:width="5dip" android:color="#FFFF00" /><!-- 描边 :边框宽度与颜色 -->
 <padding android:left="20dip" android:top="0dip" android:right="0dip" android:bottom="0dip" /><!-- 主要内容的padding 文字距离上下左右的距离 -->
 <corners  android:topLeftRadius="15dip"         
     android:topRightRadius="15dip"
          android:bottomLeftRadius="0dip"
          android:bottomRightRadius="0dip"/><!-- 圆角的半径  也可以统一设置半径 android:radius="9dip"-->

    <gradient  android:startColor="#ff8c00"  android:endColor="#FFFFFF"  android:angle="270" />     <!-- 渐变 --> 
 <solid android:color="#FFEFD5" /> <!-- 没有描边的中间部分 --><!--solid 与  gradient 只能显示在代码最后那个-->
</shape>

 

更多说明:

gradient:渐变
android:startColor和android:endColor分别为起始和结束颜色,ndroid:angle是渐变角度,必须为45的整数倍。
另外渐变默认的模式为android:type="linear",即线性渐变,可以指定渐变为径向渐变,android:type="radial",径向渐变需要指定半径android:gradientRadius="50"。

stroke:描边
android:width="2dp" 描边的宽度,android:color 描边的颜色。
我们还可以把描边弄成虚线的形式,设置方式为:
android:dashWidth="5dp"

android:dashGap="3dp"
其中android:dashWidth表示'-'这样一个横线的宽度,android:dashGap表示之间隔开的距离。

 

posted @ 2012-04-16 10:00  未来是个梦  阅读(5254)  评论(1编辑  收藏  举报