Android Drawble
来源:互联网 发布:一品威客网 知乎 编辑:程序博客网 时间:2024/05/16 06:57
1.BitmapDrawable
<?xml version="1.0" encoding="utf-8"?><bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/ic_launcher" android:tileMode="clamp" /><!--xmlns:android类型:String。定义了XML的命名空间,必须是"http://schemas.android.com/apk/res/android"。如果<bitmap>是根元素,那么他是必须的,如果是嵌套在<itme>里面,那么就不是必须的。android:src类型:Drawable resource。必需。 引用一个drawableresource.android:antialias类型:Boolean。是否开启抗锯齿。android:dither类型:Boolean。如果位图与屏幕的像素配置不同时,是否允许抖动.(例如:一个位图的像素设置是 ARGB 8888,但屏幕的设置是RGB 565)android:filter类型:Boolean。是否允许对位图进行滤波。对位图进行收缩或者延展使用滤波可以获得平滑的外观效果。android:gravity类型:关键字。定义位图的重力(gravity),如果位图小于其容器,使用重力指明在何处绘制-->
2.shapeDrawable
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <!-- shape 有4个选项 rectangle oval line ring 默认为rectangle line ring 必须通过和 stroke 属性来指定 宽度和颜色信息, 否则无法达到预期效果一起来使用 --> <!-- 这个标签表示纯色填充 通过 color 属性 即可指定填充的颜色 --> <solid android:color="#ff0000" /> <!-- stroke 边框 android:width 描边宽度 越大边缘线 越宽 android:color="#00ff00" 描边的宽度 android:dashWidth 组成虚线的宽度 android:dashGap="2sp" 虚线的间隔 dashWidth dashGap 任何一个为0 虚线的效果将不会显示 padding 包含 shap的空白 top right left bottom corners Radius 为4个角设定相同的角度 优先级最低会被其它4个属性覆盖 topLeftRadius topRightRadius bottomLeftRadius bottomRightRadius --> <stroke android:dashGap="2dp" android:dashWidth="10dp" android:width="20dp" android:color="#00ff00" /> <padding android:left="200dp" android:right="50dp" android:top="30dp" /><!-- 指定大小,一般用在imageview配合scaleType属性使用--> <size android:height="30dp" android:width="30dp" /> <corners android:bottomLeftRadius="9dp" android:bottomRightRadius="20dp" android:topLeftRadius="20dp" android:topRightRadius="9dp" /></shape>
3.gradient
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <!-- gradient 与 solid 互斥 solid 表示纯色填充 gradient 表示渐变 centerX 渐变的横坐标 centerY 渐变的纵坐标 startColor 渐变的起始色 endColor 渐变的终止色 angle 渐变的角度 默认为0 其值必须为45的倍数 0 表示从左到右 90表示从下到上 gradientRadius 渐变半径 仅当 type 等于 radial时有效 type sweep扫描 线渐变 radial 镜像渐变 linear 线性渐变,默认为线性渐变 --> <gradient android:angle="0" android:centerColor="#00ff00" android:centerX="0.5" android:centerY="0.5" android:endColor="#0000ff" android:gradientRadius="5" android:startColor="#ff0000" android:type="sweep" > </gradient></shape>
4.LayerDarwable
<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <!-- layer-list 可以包含多个item 下层的item会覆盖上层的item,通过刚合理的覆盖会实现叠加的效果 bottom left right top 相对view 的偏移量 --> <item> <shape android:shape="rectangle" > <solid android:color="#0ac39e" /> </shape> </item> <item android:bottom="16dp"> <shape android:shape="rectangle" > <solid android:color="#ffffff" /> </shape> </item> <item android:bottom="1dp" android:left="1dp" android:right="1dp"> <shape android:shape="rectangle" > <solid android:color="#ffffff" /> </shape> </item></layer-list>
5.StateListDrawble
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- SateListDrawable 对应 selector标签 系统会根据view 当前的状态从selector中选择相应的item,每个item对应一个Drable, 系统按照从上往下的顺序 查找,直至找到第一条匹配的item一般来说 默认的item都应该 放在最后的一条且不带任何状态,这样当系统没有匹配的状态时 系统就可以选择默认的一个状态 state_pressed 按下状态 按钮按下 还没有松开的状态 state_focuse 获取焦点 state_select 选择了view state_check 选中状态 选中和非选中状态 state_enable 当前view层处于可用状态 constranSize 大小是否随选择状态的改变而改变 默认为false dither 开启抖动效果 variablePading SateListDrawable 的padding 表示是否随着 其状态的改变而改变 false 表示SateListDrawable的padding是内部所有Drawable的padding最大值。 默认为false。 并不建议开启 --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="false" android:color="#ffffff"/> <!-- press --> <item android:state_pressed="true" android:color="#556699"/> <!-- focuse --> </selector></selector>
6.LevelListDrawable
7.TransitionDrawable
8.InsetDrawable
9.ScaleDrawable
10.ClipDrawable
0 0
- Android Drawble
- Android:Bitmap->Drawble->Byte[]
- Android 资源的使用之Drawble使用
- android 把bitmap转成drawble后宽高不一致的解决方法
- android 把bitmap转成drawble后宽高不一致的解决方法
- android 把bitmap转成drawble后宽高不一致的解决方法
- android 改造TextView使上下左右Drawble宽高可调
- 自定义Drawble
- 使用Drawble文件实现圆角,填充颜色,边框等属性的设置(Android)
- 关于Drawble 和Bitmap
- 自定义Drawble-Xml
- drawble用法总结
- drawble 的使用
- Drawble高效创建缩略图方法
- res下五个drawble文件夹
- drawble和bitmap的区别
- Bitmap/byte/Drawble 相互转换 + 内存剪裁
- failed to convert @drawable/ intto drawble
- 实现家庭WiFi网络全覆盖
- Visual Studio 2015常用快捷键
- window 下无法安装 node 模块的一种情况
- mybatis中自定义boolean类型转换器
- 洛谷 P1403 [AHOI2005]约数研究
- Android Drawble
- ADB学习笔记
- 设计模式(三)之建造者模式(Builder) C++实现
- [生存志] 第120节 黄帝内经素问灵枢
- des两种加密方式讲解和测试
- IntelliJ IDEA 2016.3.3 配置Tomcat 运行Web项目
- 8VC Venture Cup 2017 - Elimination RoundC. PolandBall and Forest(并查集)
- redis服务启动报未知错误--UnKnown error
- LeetCode--476. Number Complement