首页 > 代码库 > 图片的淡入淡出效果实现
图片的淡入淡出效果实现
还算简单,先发个图看看效果。
主文件:
[java] view plaincopy
- import android.app.Activity;
- import android.os.Bundle;
- import android.view.animation.AnimationUtils;
- import android.widget.ViewFlipper;
- public class TextAnimationActivity extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- ViewFlipper viewFilpper = (ViewFlipper) findViewById(R.id.flipper);
- viewFilpper.setInAnimation(AnimationUtils.loadAnimation(this,R.anim.push_in));
- viewFilpper.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.push_out));
- viewFilpper.startFlipping();
- }
- }
anim文件:
push_in.xml
[html] view plaincopy
- <?xml version="1.0" encoding="utf-8"?>
- <set xmlns:android="http://schemas.android.com/apk/res/android">
- <translate android:fromYDelta="100"
- android:toYDelta="0"
- android:duration="3000"/>
- <alpha android:fromAlpha="0.0"
- android:toAlpha="1.0"
- android:duration="3000" />
- </set>
push_out.xml
[html] view plaincopy
- <?xml version="1.0" encoding="utf-8"?>
- <set xmlns:android="http://schemas.android.com/apk/res/android">
- <translate android:fromYDelta="0"
- android:toYDelta="-100"
- android:duration="500"/>
- <alpha android:fromAlpha="1.0"
- android:toAlpha="0.0"
- android:duration="500" />
- </set>
OK!
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。