android shape的使用及渐变色、分割线、边框、半透明阴影

shape使用、渐变色、分割线、边框、半透明、半透明阴影效果。

首先简单了解一下shape中常见的属性。(详细介绍参看 api文档)


 --- 默认为rectangle
 
 
 
 
 
  -- 虚线间隔宽度

注意:

1、android:radius,半径,会被下边的单个角度半径属性覆盖,默认为1dp,

2、在使用时,如果单独设置四个角度,又大小不一致时,eclipse的graphics preview会报错。但是直接真机运行即可。(比如实线上边直角,下边屈角的效果)

Note: The shape scales to the size of the container View proportionate to the dimensions defined here, by default. When you use the shape in an ImageView, you can restrict scaling by setting the android:scaleType to "center"

举个栗子:

1、渐变色 res/drawable/gradient_box.xml:



 
 
 

如图:

android shape的使用及渐变色、分割线、边框、半透明阴影_第1张图片

2、白色边框、半透明效果



 
 
 
 

如图:

android shape的使用及渐变色、分割线、边框、半透明阴影_第2张图片   android shape的使用及渐变色、分割线、边框、半透明阴影_第3张图片

3、分割线效果:



 

如图:

android shape的使用及渐变色、分割线、边框、半透明阴影_第4张图片

4、单边屈角效果



 
 
 
 
 
 
 
 

如图:

android shape的使用及渐变色、分割线、边框、半透明阴影_第5张图片

另:附上一份颜色进制图,需要的可以查阅:http://tools.jb51.net/static/colorpicker/index.html

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

你可能感兴趣的:(android shape的使用及渐变色、分割线、边框、半透明阴影)