Android View动画(视图动画)
来源:互联网 发布:1大学生网络党校 编辑:程序博客网 时间:2024/06/05 06:52
安卓中的动画有:视图动画(也叫补间动画,tween动画)、Drawable动画(也叫Frame动画、帧动画)和Property动画(属性动画)。
视图动画
在一个视图容器内执行一系列简单变换(位移、缩小放大、旋转、透明度),使用这个动画时,控件的点击的区域还是在原来的位置上,并不会因为视图移动而点击区域发生改变。
创建视图动画有两种方式:代码创建和xml。
java类名 xml关键字 描述信息
<alpha>
渐变透明度动画效果RotateAnimation<rotate>
画面转移旋转动画效果ScaleAnimation<scale>
渐变尺寸伸缩动画效果TranslateAnimation<translate>
画面转换位置移动动画效果AnimationSet<set>
一个持有其它动画元素alpha、scale、translate、rotate或者其它set元素的容器Animation抽象类是所有补间动画类的基类,所以基类会提供一些通用的动画属性。所有视图动画都具备此属性,可以设置一个或多个。
xml属性 java方法 解释
Alpha动画属性
xml属性 java方法 解释
Rotate动画属性
xml属性 java方法 解释
RotateAnimation rotate = new RotateAnimation(float fromDegrees,float toDegrees,int pivotXType,int pivotYType);默认ABSOLUTE
RotateAnimation rotate = new RotateAnimation(float fromDegrees,float toDegrees,int pivotXType,float pivotXValue,int pivotYType,float pivotYValue);
参数1:旋转开始角度;参数2:旋转的结束角度;参数3:X轴的旋转模式,可取值ABSOLUTE 、RELATIVE_TO_SELF、RELATIVE_TO_PARENT;参数4:X坐标的伸缩值;参数5:Y轴的旋转模式,可取值ABSOLUTE 、RELATIVE_TO_SELF、RELATIVE_TO_PARENT;参数6:Y坐标的伸缩值。
Scale动画属性
xml属性 java方法 解释
ScaleAnimation scale = new ScaleAnimation(float fromX,float toX,float fromY,float toY,float pivotX,float pivotY) ;
ScaleAnimation scale = new ScaleAnimation(float fromX,float toX,float fromY,float toY,int pivotXType,float pivotXValue,int pivotYType,float pivotYValue) ;
参数1:起始X轴方向上的大小,取值0-1;参数2:结束X轴方向上的大小,取值0-1;参数3:起始Y轴方向上的大小,取值0-1;参数4:结束Y轴方向上的大小;参数5:X轴的缩放模式,RELATIVE_TO_SELEF以自己为标准、RELATIVE_TO_PARENT以父组件为标准、ABSOLUTE表示绝对位置;参数6:针对前一个参数的值,取值0-1之间;参数7和8同之前。
例:ScaleAnimation scale = new ScaleAnimation(1f,0f,1f,0f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f) ;
Translate动画属性
xml属性 java方法 解释
Animation类的方法 解释
View类的常用动画操作方法 解释
Drawable动画
Drawable动画就是Frame动画,它允许你实现像播放幻灯片一样的效果,这种动画的实质是Drawable,所以定义在res/drawable目录下。
xml和java代码都能实现
xml中使用:
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true" > true:表示执行一次,false:表示玄幻执行item:类似一帧的动画资源 <item android:drawable="" android:duration=""></item>drawable:一个frame的Drawable资源;duration:一个frame显示多长时间 </animation-list>AnimationDrawable的start()方法不能再Activity的onCreate方法中调用,因为AnimationDrawable还未完全附着到Window上,所以最好的调用时机是onWindowFocusChanged()方法中
mIvAnim.setBackgroundResource(R.drawable.drawable_anim);AnimationDrawable drawable = (AnimationDrawable) mIvAnim.getBackground();drawable.start();
- Android View动画(视图动画)
- Android View 视图动画
- Android动画之View Animation(视图动画)
- Android动画之View animation(视图动画)
- Android视图动画---View Animation
- Android视图动画(View Animation)
- Android-View Animation(视图动画)
- Android 动画之 ---- View Animation (视图动画,补间动画)
- 视图动画(View Animation)
- View Animation(视图动画)
- Android动画--视图动画
- Android动画-View动画
- android 动画 ——视图动画(View Animation)
- Android动画(2)视图动画
- Android动画(一)-视图动画
- Android动画学习-视图动画&属性动画(一)
- Android动画学习-视图动画&属性动画(二)
- android动画基础(一) View动画和属性动画
- SharePoint Server 2016 中的数据库类型和说明
- tmpfs介绍
- centos7下kafka集群搭建
- Argestes and Sequence HDU
- CUDAArray的数据存储顺序
- Android View动画(视图动画)
- 本地访问json格式文件出现XMLHttpRequest cannot load的解决方法
- org.apache.jasper.JasperException: java.lang.ClassCastException
- Redis
- 欧拉回路,欧拉路径,欧拉图详解
- 够壕!支付宝新楼“蚂蚁Z空间”启用 网友:公司缺人吗
- 请求服务器数据-------开源项目asyncHttpClient
- 树结构练习——排序二叉树的中序遍历
- MTK 6735平台 低电量强开闪光灯