我想在Android Activity屏幕上显示一张照片,从淡淡的单调棕褐色逐渐淡入到最终的全彩色。我知道如何在Graphic对象的Java Image/BufferedImage上完成它,但不幸的是我对Android编程环境一无所知。谁能帮忙?如何在Android Activity屏幕上对图像进行淡入淡出?
回答
对此的一种方法是使用动画集。看这里;
http://developer.android.com/guide/topics/resources/available-resources.html#animation
一些示例代码我已经做(无限循环淡出在这个例子中);
在动画的.xml文件中;
<alpha android:fromAlpha="1.0"
android:toAlpha="0.3"
android:duration="7000"
android:repeatMode="restart"
android:repeatCount="infinite"/>
在java文件中;
ImageView introanim = (ImageView) findViewById(R.id.introanim);
Animation StoryAnimation = AnimationUtils.loadAnimation(this, R.anim.intro_anim);
introanim.startAnimation(StoryAnimation);
你可以从你的怀旧背景/淡入到任何你想要的......
喜弘,你可以在褪色做到这一点:
ImageView myImageView= (ImageView)findViewById(R.id.myImageView);
Animation myFadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.fadein);
myImageView.startAnimation(myFadeInAnimation); //Set animation to your ImageView
和你的资源内\动画\文件夹中的动画文件fadein.xml
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="3000"/>
</set>
但对于从褐色到全彩色的逐渐淡去,哟ü必须使用TransitionDrawable
工作得很好。你可能不需要'android:repeatCount =“infinite”',虽然... – 2012-06-29 16:42:11
我想要的图像褪色(然后消失)从一次完全不透明点击为0。这里是我是如何做到的:
Animation a = new AlphaAnimation(1.00f, 0.00f);
a.setDuration(1000);
a.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
public void onAnimationEnd(Animation animation) {
yourView.setVisibility(View.GONE);
}
});
yourView.startAnimation(a);
感谢这帮助我在回收站内的动画 – AndyRoid 2015-01-01 04:43:39
- 1. 淡入淡出屏幕
- 2. android图像淡入淡出
- 3. 淡入淡出的图像
- 4. jquery淡入/淡出图像
- 5. Android图像按钮淡入淡出
- 6. Javascript图像淡入淡出?
- 7. Javascript淡入淡出图像
- 8. Javascript - 淡入淡出图像?
- 9. 图像淡入淡出
- 10. jssor淡入淡出之前在ipad上淡出图像
- 11. 淡入淡出Android中的动画图像给黑屏
- 12. 淡入淡出背景图像淡入淡出div内容
- 13. 如何在iPhone上使用openGL进行淡入淡出效果?
- 14. 在背景图像中淡入淡出
- 15. C++中带有淡入淡出图像的屏幕保护程序
- 16. 是否有可能使UIButton淡入淡出或滑出屏幕?
- 17. 将图像淡入和淡出网页
- 18. 图像之间的淡入淡出
- 19. 淡入淡出中的背景图像
- 20. 背景图像交叉淡入淡出
- 21. 使用javascript淡入/淡出图像鳍
- 22. GWT - 淡入/淡出背景图像
- 23. 淡入淡出图像容器
- 24. 淡入淡出图像到背景
- 25. 在屏幕上淡出新的背景图像
- 26. 使用java1.1淡入淡出的图像
- 27. 具有淡入淡出图像的CSS
- 28. 淡入/淡出多幅图像与jQuery
- 29. 背景图像淡入淡出与jQuery
- 30. jQuery淡入淡出图像循环
感谢乔治和麦克。我会尝试你的做法。 – 2010-04-09 12:34:06