有关Drawable状态的选择,书写规范。以及GridView、ListView几种LayoutAnimation汇总
来源:互联网 发布:淘宝旺旺在线生成代码 编辑:程序博客网 时间:2024/06/11 21:56
今天研究ApiDemo时发现谷歌官方selector书写的标准相当规范。现总结如下:
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_window_focused="false" android:state_enabled="true" android:drawable="@drawable/textfield_default" /> <item android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/textfield_disabled" /> <item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/textfield_selected" /> <item android:state_enabled="true" android:drawable="@drawable/textfield_default" /> <item android:state_focused="true" android:drawable="@drawable/textfield_disabled_selected" /> <item android:drawable="@drawable/textfield_disabled" /></selector>
ApiDemo实现的几种LayoutAnimation加载方式:
1、layout_grid_fade 图标渐显式出现
<gridLayoutAnimation xmlns:android="http://schemas.android.com/apk/res/android" android:rowDelay="50%" android:directionPriority="column" android:animation="@anim/fade" />
2、Layout 添加自定义动画出现
setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mStrings)); AnimationSet set = new AnimationSet(true); Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(1000); set.addAnimation(animation); /** * TranslateAnimation 表示位移动画。其中几种构造方法如下: * TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta) * float fromXDelta:这个参数表示动画开始的点离当前View X坐标上的差值; * float toXDelta, 这个参数表示动画结束的点离当前View X坐标上的差值; * float fromYDelta, 这个参数表示动画开始的点离当前View Y坐标上的差值; * float toYDelta)这个参数表示动画开始的点离当前View Y坐标上的差值;) * 如果view在A(x,y)点 那么动画就是从B点(x+fromXDelta, y+fromYDelta)点移动到C 点(x+toXDelta,y+toYDelta)点. * * 第二种构造方法如下: * TranslateAnimation (int fromXType, float fromXValue, int toXType, float toXValue, int fromYType, float fromYValue, int toYType, float toYValue) * fromXType:第一个参数是x轴方向的值的参照(Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF,or Animation.RELATIVE_TO_PARENT); * fromXValue:第二个参数是第一个参数类型的起始值; * toXType,toXValue:第三个参数与第四个参数是x轴方向的终点参照与对应值; * * 如果全部选择Animation.ABSOLUTE,其实就是第二个构造函数。 * */ // animation = new TranslateAnimation(// Animation.RELATIVE_TO_SELF, 0.0f,Animation.RELATIVE_TO_SELF, 0.0f,// Animation.RELATIVE_TO_SELF, -1.0f,Animation.RELATIVE_TO_SELF, 0.0f// );// // animation.setDuration(1000); animation = new RotateAnimation(15, 0, Animation.RELATIVE_TO_SELF, 0.2f, Animation.RELATIVE_TO_SELF,0f); animation.setDuration(1000); set.addAnimation(animation); LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f); ListView listView = getListView(); listView.setDivider(null); listView.setLayoutAnimation(controller);
3、ListView倒序显示加载动画
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android" android:delay="30%" android:animationOrder="reverse" android:animation="@anim/slide_right" />4、GridView随机加载显示动画
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android" android:delay="0.5" android:animationOrder="random" android:animation="@anim/fade" />
5、GridView按照方向渐显式加载
<gridLayoutAnimation xmlns:android="http://schemas.android.com/apk/res/android" android:columnDelay="0.5" android:directionPriority="row" android:direction="right_to_left|bottom_to_top" android:animation="@anim/fade" />6、GridView按照方向放大显式加载
<gridLayoutAnimation xmlns:android="http://schemas.android.com/apk/res/android" android:rowDelay="75%" android:columnDelay="0%" android:directionPriority="none" android:animation="@anim/wave_scale" />
7、TableRow 加载动画
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android" android:delay="10%" android:animationOrder="reverse" android:animation="@anim/slide_right" />
</pre><pre name="code" class="html"><pre name="code" class="html"><layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android" android:delay="10%" android:animation="@anim/slide_left" />
8、ProgressBar显示旋转动画
<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <rotate android:drawable="@drawable/spinner_76_outer_holo" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0" android:toDegrees="1080" /> </item> <item> <rotate android:drawable="@drawable/spinner_76_inner_holo" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="720" android:toDegrees="0" /> </item></layer-list>
现总结如下。以免日后遗忘~
0 0
- 有关Drawable状态的选择,书写规范。以及GridView、ListView几种LayoutAnimation汇总
- ListView,GridView之LayoutAnimation特殊动画的实现
- ListView,GridView之LayoutAnimation特殊动画的实现
- ListView,GridView之LayoutAnimation特殊动画的实现
- ListView,GridView之LayoutAnimation特殊动画的实现
- 如何规范的书写CSS书写规范以及顺序
- 有关Activity生命周期以及状态的保存操作的选择
- ListView 滑动监听的几种状态
- 介绍ListView中的几种位置关系和LayoutAnimation在listview中的应用
- CheckBox的选择状态会根据ListView或GridView的滑动而自动改变
- Activity的生命周期以及几种状态
- h5学习之4(html中颜色的几种写法和书写规范简述)
- 几点关于JS书写规范的提醒
- 有关测试用例的书写以及重要性
- Java_javadoc 书写规范 以及 命令
- ListView中嵌套GridView,ListView的问题汇总
- 文档的书写规范
- xhtml的书写规范
- Robotium android自动化测试
- 使用python将远程图片下载到本地
- JQuery mobile 各种类型页面间的跳转方式
- DAO层,Service层,Controller层、View层
- 数据中心operating system正当其时
- 有关Drawable状态的选择,书写规范。以及GridView、ListView几种LayoutAnimation汇总
- 深入理解Java虚拟机笔记---垃圾收集算法
- cxf消息拦截器
- 程序员的人生规划
- MongoDB在ubuntu上的安装
- Android中调用系统Activity
- android 自定义view添加自定义xml属性
- nsstring 初始化方法不一样,地址不一样
- 人类历史上第一位写过代码的总统