Android初级教程:shape的基本用法
来源:互联网 发布:什么手机优化软件最好 编辑:程序博客网 时间:2024/06/11 05:07
转载本文请注明出处:http://blog.csdn.net/qq_32059827/article/details/52203347 点击打开链接
在自定义进度条之前,先来学习一下shape的用法。
一、在res目录下边新建一个drawble目录(如果您会自定义状态选择器的话,这将很简单)
二、新建一个android.xml文件,找到shape,点击finish
我们可以看到shape属性并不多,截图如下:
现在逐步介绍常用的属性用法:
1、<corners />表示 “角”,表示圆角
(1)、radius : 表示半径android:radius="5dip"代表,指定圆角半径为5dip
2、<gradient /> :表示颜色渐变。放射性改变
测试上边两个属性特征:
在drawable/shapetest.xml代码如下:
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" > <corners android:radius="5dip" > </corners> <gradient android:endColor="#00ff00" android:startColor="#ff0000" /></shape>
在测试activity的布局文件引入shape.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <TextView android:textSize="22sp" android:background="@drawable/shapetest" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /></RelativeLayout>
此时显示效果图片:
好了。接着看shape的后边的几个属性:
3、<padding />表示内间距,与布局文件中的padding效果一样,就不做介绍。
4、<size />同上,可以直接在布局文件设置
5、<solid />固定颜色,设置这个原色后,放射颜色就不起作用
6、<stoke />改组件加边框线,看一下设置这个属性后,变为什么样子:
<stroke android:width="1dip" android:color="#0000ff" android:dashWidth="5dip" android:dashGap="5dip"/>
分别表示:外边框颜色宽度为1,颜色为蓝色,破折号长度为5,破折号之间的间距为5.效果截图如下:
到这里shape的基本用法就介绍完了。学习完shape基本用法,在Android简易实战系列第十七话中,完成一个自定义彩色进度条的案例
1 0
- Android初级教程:shape的基本用法
- android UI之shape的基本用法
- Android基础:shape的基本用法
- Android基础:shape的基本用法
- Android基础:shape的基本用法
- Android选择器-shape的基本用法
- Android基础:shape的基本用法
- shape的基本用法
- android shape的用法
- Android shape的用法
- Android: Selector 与 Shape 属性的一些基本用法
- Android Selector 与 Shape 基本用法
- Android Selector 与 Shape 基本用法
- Android Selector 与 Shape 基本用法
- Android Selector 与 Shape 基本用法
- Android Selector 与 Shape 基本用法
- Android Selector 与 Shape 基本用法
- Android Selector 与 Shape 基本用法
- 软考之路(五)---编译原理 概念篇
- 使用QQuickWidget和QQmlApplicationEngine的不同之处
- 抽象类和接口的小程序
- 软考之路(六)---数据库---深入浅出 三层模式两级映像
- 20160814Object-C内存管理二
- Android初级教程:shape的基本用法
- spring中bean创建的细节
- Labview 对C语言回调函数的实现
- 软考之路(七)---设计模式总结
- 浅谈数据结构——堆
- json对象的测试
- 【清华机试】质因数的个数
- 0813牛客网总结
- 软考之路(八)--- 大总结