如何在 Android 活动屏幕上淡入图像? [英] How to do a fadein of an image on an Android Activity screen?
问题描述
我想在 Android Activity 屏幕上显示一张照片,从苍白的单调棕褐色逐渐和连续淡入到最终的全彩色.我知道如何在 Java Image/BufferedImage 上为 Graphic 对象执行此操作,但不幸的是我对 Android 编程环境一无所知.有人可以帮忙吗?
I'd like to display a photo on an Android Activity screen with doing gradual and continual fade-in from pale monotone sepia to the final full color. I know how to do it on a Java Image/BufferedImage for the Graphic object but unfortunately I know nothing for the Android programming environment. Could anyone help?
推荐答案
嗨 Hiroshi 你可以为淡入做这个:
Hi Hiroshi you can do this for the fade in:
ImageView myImageView= (ImageView)findViewById(R.id.myImageView);
Animation myFadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.fadein);
myImageView.startAnimation(myFadeInAnimation); //Set animation to your ImageView
在 resanim 文件夹中,动画文件fadein.xml
and inside your resanim folder the animation file 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
but for the gradual fade in from sepia to the full color, you must use TransitionDrawable
这篇关于如何在 Android 活动屏幕上淡入图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!