软件开发layer-list学习
来源:互联网 发布:淘宝能代理几个分销商 编辑:程序博客网 时间:2024/06/05 19:44
1.Shape
简介
作用:XML中定义的几何形状
位置:res/drawable/文件的名称.xml
使用的方法:
Java代码中:R.drawable.文件的名称
XML中:Android:background="@drawable/文件的名称"
属性:
<shape> Android:shape=["rectangle" | "oval" | "line" | "ring"]其中rectagle矩形,oval椭圆,line水平直线,ring环形
shape中子节点的常用属性:
渐变:<gradient> 起始颜色: Android:startColor 结束颜色 : Android:endColor 渐变角度,0从左到右,90表示从下到上,数值为45的整数倍,默认为0: Android:angle
Android:type 渐变的样式 :liner线性渐变 radial环形渐变 sweep<solid > 填充填充的颜色: Android:color <stroke >描边描边的宽度: Android:width 描边的颜色: Android:color 表示'-'横线的宽度: Android:dashWidth表示'-'横线之间的距离: Android:dashGap <corners >圆角圆角的半径 值越大角越圆:Android:radius 右上圆角半径: Android:topRightRadius 右下圆角角半径: Android:bottomLeftRadius 左上圆角半径: Android:topLeftRadius 左下圆角半径: Android:bottomRightRadius<padding >填充底部填充: android:bottom="1.0dip" 左边填充: android:left="1.0dip" 右边填充: android:right="1.0dip" 上面填充: android:top="0.0dip"
2.Selector
简介
根据不同的选定状态来定义不同的现实效果
分为四大属性:
android:state_selected 选中android:state_focused 获得焦点android:state_pressed 点击android:state_enabled 设置是否响应事件,指所有事件
另:
android:state_window_focused 默认时的背景图片引用位置:res/drawable/文件的名称.xml
使用的方法:
Java代码中:R.drawable.文件的名称XML中:Android:background="@drawable/文件的名称"
[html] view plain copy
在CODE上查看代码片派生到我的代码片
<?xml version="1.0" encoding="utf-8" ?> <selector xmlns:Android="http://schemas.android.com/apk/res/android"> <!-- 默认时的背景图片--> <item Android:drawable="@drawable/pic1" /> <!-- 没有焦点时的背景图片 --> <item Android:state_window_focused="false" android:drawable="@drawable/pic_blue" /> <!-- 非触摸模式下获得焦点并单击时的背景图片 --> <item Android:state_focused="true" android:state_pressed="true" android:drawable= "@drawable/pic_red" /> <!-- 触摸模式下单击时的背景图片--> <item Android:state_focused="false" Android:state_pressed="true" Android:drawable="@drawable/pic_pink" /> <!--选中时的图片背景--> <item Android:state_selected="true" android:drawable="@drawable/pic_orange" /> <!--获得焦点时的图片背景--> <item Android:state_focused="true" Android:drawable="@drawable/pic_green" /> </selector>
3.layer-list
简介:
将多个图片或上面两种效果按照顺序层叠起来
例子:
[html] view plain copy 在CODE上查看代码片派生到我的代码片<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <bitmap android:src="@drawable/android_red" android:gravity="center" /> </item> <item android:top="10dp" android:left="10dp"> <bitmap android:src="@drawable/android_green" android:gravity="center" /> </item> <item android:top="20dp" android:left="20dp"> <bitmap android:src="@drawable/android_blue" android:gravity="center" /> </item> </layer-list> [html] view plain copy 在CODE上查看代码片派生到我的代码片<ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/layers" />
4.最后
以上三个标签可以揉合到一块儿来使用,所要实现的效果就是上面三种标签的说明,比如下面这个例子: [html] view plain copy
在CODE上查看代码片派生到我的代码片
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true"> <layer-list> <item android:bottom="8.0dip"> <shape> <solid android:color="#ffaaaaaa" /> </shape> </item> <item> <shape> <corners android:bottomLeftRadius="4.0dip" android:bottomRightRadius="4.0dip" android:topLeftRadius="1.0dip" android:topRightRadius="1.0dip" /> <solid android:color="#ffaaaaaa" /> <padding android:bottom="1.0dip" android:left="1.0dip" android:right="1.0dip" android:top="0.0dip" /> </shape> </item> <item> <shape> <corners android:bottomLeftRadius="3.0dip" android:bottomRightRadius="3.0dip" android:topLeftRadius="1.0dip" android:topRightRadius="1.0dip" /> <solid android:color="@color/setting_item_bgcolor_press" /> </shape> </item> </layer-list> </item> <item> <layer-list> <item android:bottom="8.0dip"> <shape> <solid android:color="#ffaaaaaa" /> </shape> </item> <item> <shape> <corners android:bottomLeftRadius="4.0dip" android:bottomRightRadius="4.0dip" android:topLeftRadius="1.0dip" android:topRightRadius="1.0dip" /> <solid android:color="#ffaaaaaa" /> <padding android:bottom="1.0dip" android:left="1.0dip" android:right="1.0dip" android:top="0.0dip" /> </shape> </item> <item> <shape> <corners android:bottomLeftRadius="3.0dip" android:bottomRightRadius="3.0dip" android:topLeftRadius="1.0dip" android:topRightRadius="1.0dip" /> <solid android:color="@color/setting_item_bgcolor" /> </shape> </item> </layer-list> </item> </selector>
1 0
- 软件开发layer-list学习
- android layer-list 学习
- layer-list学习
- android学习笔记:layer-list
- Android学习之layer-list
- Android中layer-list学习
- Android样式的开发:Layer-list篇
- Android样式的开发:layer-list篇
- Android样式的开发:layer-list篇
- Android样式的开发:layer-list篇
- Android样式的开发:layer-list篇
- Android样式的开发:layer-list篇
- Android样式开发--layer-list篇
- Android样式的开发:layer-list篇
- Android样式的开发:layer-list篇
- Android样式的开发:layer-list篇
- Android样式的开发:layer-list篇
- Android样式的开发:layer-list篇
- Servlet基本接口与类
- SlidingMenu ViewPager Fragment GSON 网络解析 网络请求 ListView
- 上拉加载显示不同的item
- kingshard--一个支持sharding的MySQL Proxy项目
- Android下载网络图片,ImageView读取本地图片
- 软件开发layer-list学习
- mysql 复杂sql子查询的实例
- 十独吟 之一 李清照
- 开源框架下载地址
- androlyze.py使用方法【二】
- 使用 Charles 获取 https 的数据
- i2c-dev和spi-dev
- 第三方登陆跳转传递图片和名字
- oracle表碎片整理