我想在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