首页>代码>Android通过ListView实现各种Animation动画特效代码>/ListAnimationDemo/src/com/example/frameanimationdemo/AnimationActivity.java
package com.example.frameanimationdemo; import android.app.Activity; import android.content.Intent; import android.graphics.drawable.AnimationDrawable; import android.media.AudioManager; import android.media.SoundPool; import android.os.Bundle; import android.view.View; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.ImageView; import android.widget.TextView; public class AnimationActivity extends Activity { private ImageView iv; private TextView tv; private Animation anim; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.animation_main); init(); } private void init(){ iv = (ImageView) findViewById(R.id.iv1); tv = (TextView) findViewById(R.id.tv); Intent intent = getIntent(); int i = intent.getIntExtra("position", BIND_ADJUST_WITH_ACTIVITY); switch (i) { case 0: Frame(); break; case 1: rotate(); break; case 2: translate(); break; case 3: alpha(); break; case 4: scale(); break; case 5: AnimationSet(); break; } iv.setAnimation(anim); } private void soundPool(){ SoundPool pool=new SoundPool(1, AudioManager.STREAM_MUSIC, 1); int i=pool.load(this,R.raw.ring, 1); pool.play(i, 1, 1, 1, 1, 1); } public void btnBack(View v) { Intent intent = new Intent(AnimationActivity.this, MainActivity.class); startActivity(intent); } private void Frame() { tv.setBackgroundResource(R.drawable.frame); AnimationDrawable ab = (AnimationDrawable) tv.getBackground(); ab.start(); } private void alpha() { anim = AnimationUtils.loadAnimation(this, R.anim.alpha); } private void rotate() { anim = AnimationUtils.loadAnimation(this, R.anim.rotate); } private void scale() { anim = AnimationUtils.loadAnimation(this, R.anim.scale); } private void translate() { anim = AnimationUtils.loadAnimation(this, R.anim.translate); } private void AnimationSet() { anim = AnimationUtils.loadAnimation(this, R.anim.anim_set); } }
最近下载更多
wyx065747 LV67
2021年6月26日
1112zcvsyf LV1
2020年9月9日
藤井旋风 LV4
2019年12月14日
女方面 LV18
2019年11月5日
wangshihua LV19
2019年5月10日
sunchuan33 LV2
2019年3月31日
爱情的本质 LV15
2019年3月18日
912396638 LV2
2018年12月28日
5255tkw LV1
2018年12月18日
tanha13 LV1
2018年9月2日
最近浏览更多
qazwer11 LV5
2023年5月22日
倾城之恋1 LV5
2023年5月21日
lasherry LV2
2023年2月14日
362255 LV1
2022年12月28日
molu123456
2022年12月12日
暂无贡献等级
GZW012345 LV8
2022年5月23日
cxywt12 LV2
2022年5月20日
2424860647
2022年1月8日
暂无贡献等级
DDheYUER LV1
2021年12月7日
18356557758 LV5
2021年11月14日