Cihad Turhan
Cihad Turhan

Reputation: 2849

How to play an animated gif (or a video) on the background of a layout?

In my spare time I'm learning android. I want to create a layout with a background image which includes an animation. I know how to use linearLayout.setBackgroundDrawable(R.drawable.BlaBla) but if I place a gif image it becomes a static image but not animated. Also, I'm not sure if I can play a video on it. Can anyone post a simple code or just give the directions about that if possible? Minsdk version will be 8 (2.2).

PS: I know I can use media to play videos using VideoView but it's not a layout, therefore, I can't add some views on it. Please don't suggest that.

Upvotes: 0

Views: 2518

Answers (2)

Chronos
Chronos

Reputation: 1962

Maybe you can try a webView, I've never tested that:

WebView myWebView = (WebView) findViewById(R.id.webview);                   
myWebView.loadUrl("http://img.gif");

Upvotes: 0

Dusko
Dusko

Reputation: 650

I don't think you can just use gif.

Maybe this will help if you want to animate something: http://developer.android.com/guide/topics/resources/animation-resource.html

With video, I think you should not just put it in background but use media player and then perhaps have some layouts on top if you want to overlay it with some info.

Hope this helped.

Upvotes: 1

Related Questions