Animation anim = AnimationUtils.loadAnimation(common.context,
R.anim.intro);
anim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
common.isScreenAnimating = true;
}
@Override
public void onAnimationEnd(Animation animation) {
common.isScreenAnimating = false;
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
anim.reset();
RelativeLayout container = (RelativeLayout)getActivity().findViewById(R.id.container);
container.clearAnimation();
container.startAnimation(anim);
here is the activity layout
<RelativeLayout xmlns:android="..."
xmlns:tools="..."
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:ignore="MergeRootFrame">
<fragment
android:id="@+id/puzzleFragment"
android:name="logic.PuzzleFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:tag="puzzleFragmentTag"
android:layout_alignParentTop="true"
tools:layout="@layout/puzzle_layout" />
Here is the fragment layout
<RelativeLayout xmlns:android="..."
xmlns:tools="..."
android:id="@+id/puzzleLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="logic.PuzzleFragment">
<logic.PuzzleSurface
android:id="@+id/puzzle"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<Button
android:id="@+id/nextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:contentDescription="@string/continue_desc"
android:text="@string/next_image"
android:visibility="invisible" />
<ImageButton
android:id="@+id/devartButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:contentDescription="@string/deviantart_link_desc"
android:scaleType="fitCenter"
android:src="@mipmap/devart"
android:visibility="invisible" />
<ImageButton
android:id="@+id/wordpressButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:contentDescription="@string/wordpress_link_desc"
android:scaleType="fitCenter"
android:src="@mipmap/wordpress"
android:visibility="invisible" />