Android中Shape的了解
2013-11-09 09:33
309 查看
在res/drawable下的XML文件有Shape这样的一个属性,这个属性的主要作用是对一些UI进行美化、设置指定形状等
第一种为矩形,第二种为椭圆,第三种为线形,第四种为环形。开发中使用矩形和椭圆较多。
在解释属性的意思之前,先把layout中的布局贴出来
接下来说说其里面的属性
(1)solid 实心
(2)conners 圆角
(3)gradient 渐变
type:
linear是线性渐变,从左到右或从上到下;
sweep径向渐变,是圆心到圆边;
radial是角度渐变,按照角度来变换颜色。
(4)stroke 描边
(5)padding 间距
(6)size 大小
下面这两个属性在Layout的XML文件中经常配置,这里不解释了。
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" android:shape="oval" android:shape="line" android:shape="ring"> </shape>
第一种为矩形,第二种为椭圆,第三种为线形,第四种为环形。开发中使用矩形和椭圆较多。
在解释属性的意思之前,先把layout中的布局贴出来
<Button android:layout_width="100dp" android:layout_height="40dp" android:text="你好呀" android:background="@drawable/myshape"/> //这里就是引用shape属性文件
接下来说说其里面的属性
(1)solid 实心
<solid android:color="#FF0000" /> //为UI内部填充颜色
(2)conners 圆角
<corners android:radius="15dp" //把所有圆角的半径设为15dp,而下面是分别设四个角 android:topLeftRadius="5dp" android:topRightRadius="8dp" android:bottomLeftRadius="6dp" android:bottomRightRadius="10dp"/>
(3)gradient 渐变
<gradient android:startColor="#000000" android:endColor="#FFFFFF" android:angle="180" //渐变角度 android:type="linear"/>
type:
linear是线性渐变,从左到右或从上到下;
sweep径向渐变,是圆心到圆边;
radial是角度渐变,按照角度来变换颜色。
(4)stroke 描边
<stroke android:color="#000000" android:dashWidth="3dp" //“-”的宽度 android:width="2dp" //线的宽度 android:dashGap="3dp"/> //间隔
(5)padding 间距
(6)size 大小
下面这两个属性在Layout的XML文件中经常配置,这里不解释了。
相关文章推荐
- Android中常常使用shape来定义控件的一些显示属性,今天看了一些shape的使用,对shape有了大体的了解,稍作总结: 先看下面的代码: <shape>
- Android中的Shape使用,了解一下Shape下面有哪些标签,都代表什么意思?
- Android-drawable-shape
- android shape的使用
- Android 使用Shape自定义背景
- 阅读《Android 从入门到精通》(1)——了解 Android 开发
- Android 开发-Shape相关
- android shape 的应用
- android触控,先了解MotionEvent(一)
- android WebView 初步了解
- Android开发:shape和selector和layer-list的(详细说明)
- Android动画篇(二):颜色和形状改变的ChangeShapeAndColorButton
- Android:shape和selector使用
- 你真的了解Android密钥库吗?
- 我的Android进阶之旅------>Android关于ImageSpan和SpannableString的初步了解
- Android-Activity所应该了解的大概就这样。(上)
- android 初步了解应用Gson 解析Json数据
- Android中的shape属性及详解
- android画图-----shape的使用文档…
- Android OkHttp完全解析 是时候来了解OkHttp了