Android animation补间动画
来源:互联网 发布:seo的意思 编辑:程序博客网 时间:2024/05/21 17:53
MainActivity
package cn.bgs.fouranimation;
import android.os.Bundle;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AlphaAnimation;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.ImageView;
public class MainActivity extends Activity implements OnClickListener {
private Button mBtn_shen,mBtn_jian,mBtn_wei,mBtn_xuan;
private ImageView mImg;
private TranslateAnimation translate;//位移
private RotateAnimation rotate;//旋转
private ScaleAnimation scale;//伸缩
private AlphaAnimation alpha;//渐变
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
}
private void initView() {
mBtn_shen=(Button) findViewById(R.id.mBtn_shen);
mBtn_jian=(Button) findViewById(R.id.mBtn_jian);
mBtn_wei=(Button) findViewById(R.id.mBtn_wei);
mBtn_xuan=(Button) findViewById(R.id.mBtn_xuan);
mImg=(ImageView) findViewById(R.id.mImg);
mBtn_shen.setOnClickListener(this);
mBtn_jian.setOnClickListener(this);
mBtn_wei.setOnClickListener(this);
mBtn_xuan.setOnClickListener(this);
}
@Override
public void onClick(View v) {
int ID =v.getId();
switch (ID) {
case R.id.mBtn_shen:
scale=new ScaleAnimation(1f, 5f, 1f, 5f);
scale.setDuration(3000);
scale.setInterpolator(new LinearInterpolator());
scale.setRepeatCount(6);
mImg.startAnimation(scale);
break;
case R.id.mBtn_jian:
alpha=new AlphaAnimation(0f, 1.0f);
alpha.setDuration(3000);
alpha.setInterpolator(new LinearInterpolator());
alpha.setRepeatCount(5);
mImg.startAnimation(alpha);
break;
case R.id.mBtn_wei:
translate=new TranslateAnimation(0, 100, 0, 100);
translate.setDuration(3000);
translate.setInterpolator(new LinearInterpolator());
translate.setRepeatCount(5);
translate.setFillAfter(true);
mImg.startAnimation(translate);
break;
case R.id.mBtn_xuan:
rotate=new RotateAnimation(0, 180);
rotate.setDuration(3000);
rotate.setInterpolator(new LinearInterpolator());
rotate.setRepeatCount(5);
mImg.startAnimation(rotate);
break;
default:
break;
}
}
}
XML
activity_main
<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"
tools:context=".MainActivity"
android:orientation="vertical">
<Button
android:id="@+id/mBtn_shen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="伸缩"
/>
<Button
android:id="@+id/mBtn_jian"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="渐变"
/>
<Button
android:id="@+id/mBtn_wei"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="位移"
/>
<Button
android:id="@+id/mBtn_xuan"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="旋转"
/>
<ImageView
android:id="@+id/mImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
android:layout_gravity="center"
/>
</LinearLayout>
- Android Animation 补间动画
- Android animation补间动画
- Android 动画--补间动画(Tween Animation)
- Android-Animation动画之Tween Animation补间动画
- android tween animation 补间动画
- Android Animation之补间动画
- android补间动画(Tween Animation)
- Animation补间动画
- Android -- Animation 动画效果, 帧动画 和 补间动画
- android 动画 补间动画,渐变动画 Tween Animation
- Android 动画之 ---- View Animation (视图动画,补间动画)
- Android补间动画(View Animation,Tweened Animation)
- Android Animation 之 View Animation(补间动画)
- android tween animation 补间动画 xml设置动画属性
- Android动画之补间动画(Tween Animation)
- Android Animation动画详解(一): 补间动画
- Android 动画解析(二) 补间动画(Tween Animation)
- Android动画之补间动画(Tween Animation)
- java 传值与传引用小例子
- 请你原谅我
- 详谈Java设计模式之外观模式(门面模式)
- 使用wireshark抓包工具深入理解TCP连接的三次握手。
- JAVA的可变类与不可变类
- Android animation补间动画
- 高斯函数积分运算 + 指数函数积分计算
- android学习(二)
- 基本光照
- Linux 条件判断式
- PLSQL连Oracle数据库Could not load "……\bin\oci.dll"
- 编写Dockerfile
- Centos7使用yum安装程序软件时提示未找到安装包解决方法
- 分布式与集群