I have been trying to get it to work using this thread but can't seem to get it to work.
I am trying to get the screen to alternate between two layouts and I have tried lots of different things from state list drawables, to shape drawables, and even flipViews(flipViews didn't work because you cannot change the background, just the foreground).
Right now I am getting a null pointer. If you would like to point out that I can not use a layout in an animation then please do so as it's probably the problem but I can't be sure. Any solution to reach my end goal is appreciated.
My Oncreate contains the following(minus the standard stuff)
ImageView mainimage = (ImageView) findViewById(R.id.main);
mainimage.setBackgroundResource(R.anim.blink);
AnimationDrawable blinkAnimation = (AnimationDrawable) mainimage.getBackground();
blinkAnimation.start();
My Animation file contains this:(minus the utf stuff)
<
animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/royalblue" android:duration="200" />
<item android:drawable="@drawable/blank" android:duration="200" />
</animation-list>
The Main in the Image view is just this blank xml file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</LinearLayout>
This is the layout I have placed in the drawable folder because I want it to be a frame in the animation.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/blinkBlue"
android:background="@color/royalBlue"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</LinearLayout>
This is the other layout I have placed in the drawable folder because I want it to be a frame in the animation.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/blinkBlack"
android:background="@color/black"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</LinearLayout>
I know that this is quite late response but for the others who are facing the same issue here is my solution:
Where amin_list is: