如何在 Android 活动屏幕上淡入图像?
我想在 Android 活动屏幕上显示一张照片,并从浅单调的棕褐色逐渐持续淡入到最终的全色。我知道如何在 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Hiroshi 您好,您可以对淡入执行此操作:
在 res\anim\ 文件夹中的动画文件 fadein.xml
但要从棕褐色逐渐淡入全色,您必须使用 TransitionDrawable
Hi Hiroshi you can do this for the fade in:
and inside your res\anim\ folder the animation file fadein.xml
but for the gradual fade in from sepia to the full color, you must use TransitionDrawable
我希望图像在从完全不透明度单击到 0 后淡出(然后消失)。我是这样做的:
I wanted an image to fade (and then disappear) once clicked from full opacity to 0. Here is how I did it:
一种方法是使用动画集。参见这里;
http://developer.android.com/guide/topics/resources /available-resources.html#animation
我完成的一些示例代码(在此示例中无限循环淡出);
在动画.xml文件中;
在java文件中;
你可以从你的棕褐色背景/图片淡入任何你想要的......
One method for this would be to use the animation set. See here;
http://developer.android.com/guide/topics/resources/available-resources.html#animation
Some example code I have done (infinite loop fade out in this example) ;
In the animation .xml file;
In the java file;
You could fade from your sepia background/picture to whatever you want...
另一个更简单的解决方案是只需将一个存根 onClick 方法放入您想要淡入淡出的 ImageView 中,然后在该方法中添加以下内容:
Another much simpler solution is to just put a stub onClick method to your ImageView you want to fade, then inside the method you add this: