I am new to Android animation, and I seem to have a simple problem ... I have a splash / load screen that I want to turn off when this is done, and then show the application.
My layout looks something like this (styles just set the background image):
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/homeParentContainer" style="@style/LayoutWithBgStyle" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout android:id="@+id/homeSplashLayout" style="@style/LayoutWithSplashStyle" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_alignParentTop="true" > </LinearLayout> <LinearLayout android:id="@+id/homeMainLayout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:orientation="vertical" android:visibility="gone" > </LinearLayout> </RelativeLayout>
Then I tried two different approaches to fading the splash screen and setting up the main screen:
final Animation fadeOut = AnimationUtils.loadAnimation(this, android.R.anim.fade_out); final View splash = findViewById(R.id.homeMainLayout); fadeOut.setAnimationListener(new AnimationAdapter() { @Override public void onAnimationEnd(final Animation animation) { splash.setVisibility(View.GONE); findViewById(R.id.homeMainLayout).setVisibility(View.VISIBLE); } }); splash.startAnimation(fadeOut);
Then I tried my own animation:
final AlphaAnimation fadeOut = new AlphaAnimation(1.0F, 0.0F); fadeOut.setDuration(1000); final View splash = findViewById(R.id.homeMainLayout); fadeOut.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(final Animation animation) { splash.setVisibility(View.GONE); findViewById(R.id.homeMainLayout).setVisibility(View.VISIBLE); } }); splash.startAnimation(fadeOut);
And I get the startAnimation code, but the animation never starts, and I never get the onAnimationEnd () call. What did I forget to turn on to start the animation?
source share