shape标签总结

来源:互联网 发布:那种牌子的网络电视好 编辑:程序博客网 时间:2024/05/17 18:26

android开发中经常用到shape,有些标签总是忘记,所以今天就写下来。

shape标签的总结:

1.solid:里面只有一个属性,color属性。所以solid是作用就是对设置shape的控件的颜色背景。

2.gradient:这个标签用的不多,但是也有用的时候。

gradient属性有: 

android:startColor=""
        android:centerColor=""
        android:endColor=""
        android:useLevel=""
        android:angle=""
        android:type=""
        android:centerX=""
        android:centerY=""
        android:gradientRadius=""

其中android:startColor是指渐变刚开始显示的颜色,

android:centerColor是渐变中间颜色,

android:endColor是渐变结束时的颜色,

android:useLevel的值只有boolean值,true和false,就是是否使用LevelListDrawable中的Drawable资源,如果是true就是使用Drawable资源,如果false就不使用drawable资源。

android:angle是渐变的方向,常用的值有0,90,180,270.其中0和180方向相反,0是从左向右,180则是从右向左;而270和90也是方向相反的,270是从上向下;

android:type是渐变的类型,有线性渐变(linear),放射性渐变(radial),扫描渐变(sweep);

android:centerX和android:centerY都是渐变中心的坐标,其中x是渐变中心的x坐标,y是渐变中心的y坐标。

android:gradientRadius直接翻译过来的意思是“渐变半径”,也确实是渐变半径,不过是要在渐变有半径时才能使用,也就是渐变类型是放射性渐变时才能使用,否则不行。

3.stroke是设置设置shape的控件的边标签,的其中的属性有:

        android:width=""
        android:color=""
        android:dashWidth=""
        android:dashGap=""其中android:width是指边的宽度,android:color颜色;android:dashWidth是设置边的线为虚线时一个虚线的宽度(左右宽度),android:dashWidth是指虚线与虚线之间的间隔。

4.corners是设置控件四个角的半径的,它的属性有:

android:bottomLeftRadius=""
        android:bottomRightRadius=""
        android:radius=""
        android:topLeftRadius=""
        android:topRightRadius=""

见名知意不做多介绍。

5.padding:是设置内容据边框的距离:

其中的属性有:

android:bottom=""
        android:left=""
        android:right=""
        android:top=""

见名知意不做多介绍。

0 0
原创粉丝点击