I want to create a background that covers the whole screen of my Activity. Just like:
android:background="@drawable/background"
But I want this background to be animated
(60 frames), looping and target as many device resolutions as possible.
I tried to do a drawble
.jpg
sequence, but the problem is that I use 1920x1080, and the logcat while trying to test it on the emulator, the application crashes, and LogCat gives me en error saying, not enough memory
Then I tried to import a video
of my sequence and set it to play on the background. But I don't know where to put the video
in my res
folder and call it from there with SetVideoPath()
, in order to play it.
What is the best approach for an animated background, that covers multiple devices with different resolutions?
@Arun C Thomas
I still get an error in logcat,
OutOfMemoryError
my code is this:
package combiolab.biolab;
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.opengl.GLSurfaceView;
import android.opengl.GLSurfaceView.Renderer;
import android.os.Bundle;
import android.view.WindowManager;
public class MainActivity extends Activity {
private Renderer graphicsRenderer;
//public static String gl;
AnimationDrawable anim;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
GLSurfaceView myGLSurfaceView = (GLSurfaceView) findViewById(R.id.gl);
myGLSurfaceView.setEGLConfigChooser(true);
myGLSurfaceView.setRenderer(graphicsRenderer);
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<android.opengl.GLSurfaceView
android:id="@+id/gl"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</android.opengl.GLSurfaceView>
</RelativeLayout>