1
I made an app with an animated background, here’s the code:
Main layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:orientation="vertical"
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=".Main" >
...
The animation list:
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/matrix_39" android:duration="100" />
<item android:drawable="@drawable/matrix_38" android:duration="100" />
<item android:drawable="@drawable/matrix_37" android:duration="100" />
<item android:drawable="@drawable/matrix_36" android:duration="100" />
...
The java implementation:
public class Main extends Activity {
LinearLayout bck;
AnimationDrawable ad;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bck = (LinearLayout) findViewById(R.id.background);
bck.setBackgroundResource(R.drawable.progress_animation);
ad = (AnimationDrawable) bck.getBackground();
ad.start();
}
Well, it works great as a full screen animated backdrop, but I’d like to repeat the animated background image. There’s a way?