android动画基础--旋转移动平移缩放
来源:互联网 发布:视频软件破解版 编辑:程序博客网 时间:2024/04/29 05:42
package com.imooc.viewanim;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.animation.AlphaAnimation;import android.view.animation.Animation;import android.view.animation.AnimationSet;import android.view.animation.RotateAnimation;import android.view.animation.ScaleAnimation;import android.view.animation.TranslateAnimation;public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void btnAlpha(View view) { //透明度动画 public AlphaAnimation(float fromAlpha, float toAlpha){} AlphaAnimation aa = new AlphaAnimation(0, 1); //持续时间 aa.setDuration(1000); view.startAnimation(aa); } public void btnRotate(View view) {// 旋转动画 public RotateAnimation(float fromDegrees, float toDegrees, float pivotX, float pivotY){}// 分别对应起始角度(toDegrees-fromDegrees),旋转中心点。 RotateAnimation ra = new RotateAnimation(90, 240, 50, 50); ra.setDuration(1000); view.startAnimation(ra); } public void btnRotateSelf(View view) { //旋转动画,设置旋转参考系 RotateAnimation ra = new RotateAnimation(0, 360, RotateAnimation.RELATIVE_TO_SELF, 0.5F, RotateAnimation.RELATIVE_TO_SELF, 0.5F); ra.setDuration(1000); view.startAnimation(ra); } public void btnTranslate(View view) { //平移动画 //自身中点做坐标原点(0,0) 向右移动200,向下移动300 TranslateAnimation ta = new TranslateAnimation(0, 200, 0, 300); ta.setDuration(1000); view.startAnimation(ta); } public void btnScale(View view) { //缩放动画 public ScaleAnimation(float fromX, float toX, float fromY, float toY){}// 向右放大2,向下放大2 ,后恢复 ScaleAnimation sa = new ScaleAnimation(0, 2, 0, 2); sa.setDuration(1000); view.startAnimation(sa); } public void btnScaleSelf(View view) { //缩放动画,设置缩放中心点。 ScaleAnimation sa = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5F, Animation.RELATIVE_TO_SELF, 0.5F); sa.setDuration(1000); view.startAnimation(sa); } //动画集合 public void btnSet(View view) { AnimationSet as = new AnimationSet(true); as.setDuration(1000); AlphaAnimation aa = new AlphaAnimation(0, 1); aa.setDuration(1000); as.addAnimation(aa); TranslateAnimation ta = new TranslateAnimation(0, 100, 0, 200); ta.setDuration(1000); as.addAnimation(ta); view.startAnimation(as); }}
<LinearLayout 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" android:paddingLeft="@dimen/activity_horizontal_margin" android:orientation="vertical" android:gravity="center_horizontal" tools:context=".MainActivity"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Alpha" android:layout_margin="10dp" android:onClick="btnAlpha" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Rotate" android:layout_margin="10dp" android:onClick="btnRotate" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Rotate_self" android:layout_margin="10dp" android:onClick="btnRotateSelf" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Translate" android:layout_margin="10dp" android:onClick="btnTranslate" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Scale" android:layout_margin="10dp" android:onClick="btnScale" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Scale_Self" android:layout_margin="10dp" android:onClick="btnScaleSelf" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Anim Set" android:layout_margin="10dp" android:onClick="btnSet" /></LinearLayout>
0 0
- android动画基础--旋转移动平移缩放
- Android动画基础:平移、缩放、旋转、透明度
- android动画(平移,旋转,缩放,透明度)
- UI基础第一弹:旋转,平移,缩放动画
- android 中四种补间动画(透明,平移,缩放,旋转)
- Android 实现属性动画平移,旋转,缩放,渐变 《H》
- Android动画复习(包括缩放动画、平移动画、旋转动画、透明度动画)
- Android 图片旋转 缩放 平移
- 动画:加速 平移 缩放 通明 旋转
- 补间动画 旋转 平移 缩放 透明
- Android 补间动画(动画列表,平移,旋转,缩放,渐变,动画集合)
- android自定义动画平移旋转
- 【Android开发】动画范例2-旋转、平移、缩放和透明度渐变的补间动画
- Android 图片的平移、缩放、旋转demo
- Android 可平移,缩放,旋转的ImageView
- Android OpenGL ES 绘图 -- 缩放、平移、旋转
- 安卓动画(旋转,平移,透明,缩放,帧动画)
- Android 通过Animate硬编码实现简单的平移、旋转、缩放及透明度动画过程
- hdu3979_Monster
- MFC中的L和_T宏
- 数组合并删除两个相同元素方法
- fedora切换至root账户
- CSS截取显示字符串
- android动画基础--旋转移动平移缩放
- C++封装python接口(libboost-python)
- [JZOJ4622] 亚瑟王之宫
- iMessage与微信
- js trim方法
- MySQL 性能优化的最佳20多条经验分享
- 【9504】装载问题
- 将ppt转换成pdf格式的方法
- Ubuntu安装默认的JDK/JRE