开发者

Animate layout background image changes

开发者 https://www.devze.com 2023-04-05 08:10 出处:网络
Is it possible to animate the background image of a layout (RelativeLayout, LinearLayout, etc.) in Android? In one of my applications I am fetching an image from the internet and displaying it as the

Is it possible to animate the background image of a layout (RelativeLayout, LinearLayout, etc.) in Android? In one of my applications I am fetching an image from the internet and displaying it as the background image once it's loaded. It would be really cool if the background image was swapped out using a fade effect or something like that.

I've tried quite a bit, but couldn't seem to find a solution. It's always the layout that's 开发者_如何学编程animating and not the image itself.


Might be your best bet to just layer your layout in a FrameLayout or RelativeLayout with a ViewSwitcher behind it. See the demo (and related layouts) in the Android API Demos app (that uses an ImageSwitcher, which is a special-case adapter-based subclass of ViewSwitcher). It does mean an extra ViewGroup level in your app, but unless you're doing something especially complicated (nesting these in ListView rows or something) it should perform just fine, and handles the transition animations for you.

You could also just use WebImageView from DroidFu, which does most of the annoying legwork for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消