Calling a new activity while rotating the ImageView



I am trying out animation in android. I want to rotate the image view only without disturbing the horizontal scroll view below it. Also, when the animation is complete I want to start a new activity. I do not want to use fragments as I want to start a new activity when the flip is completed. As, of now the application works without errors but it not smooth and the Horizontal scroll view also rotates. Also, it doesn't seem like that it is rotating. When I put alpha properties in the rotate_in.xml it gives an error that "The child element must be well formatted" Kindly help. Here are the source codes:


Layout1:



LinearLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:layout_width="match_parent"
android:layout_height="match_parent"
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="com.example.fromscratch.MainActivity" >


<ImageView
android:layout_width="250dp"
android:layout_height="250dp"
android:src="@drawable/you"
android:id="@+id/you" >
</ImageView>
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp" >

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="10dp">

<ImageButton
android:id="@+id/date"
android:layout_width="100dip"
android:layout_height="100dip"
android:layout_marginTop="26dp"
android:scaleType="fitXY"
android:src="@drawable/date" />

<ImageButton
android:id="@+id/mission"
android:layout_width="100dip"
android:layout_height="100dip"
android:layout_marginTop="26dp"
android:scaleType="fitXY"
android:src="@drawable/mission" />

<ImageButton
android:id="@+id/youu"
android:layout_width="100dip"
android:layout_height="100dip"
android:layout_marginTop="26dp"
android:scaleType="fitXY"
android:src="@drawable/you" />

<ImageButton
android:id="@+id/competitionn"
android:layout_width="100dip"
android:layout_height="100dip"
android:layout_marginTop="26dp"
android:scaleType="fitXY"
android:src="@drawable/competition" />


</LinearLayout>
</HorizontalScrollView>

</LinearLayout>


Layout2:



<LinearLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:layout_width="match_parent"
android:layout_height="match_parent"
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="com.example.fromscratch.MainActivity"
android:orientation="vertical">


<ImageView
android:layout_width="250dp"
android:layout_height="250dp"
android:src="@drawable/competition"
android:id="@+id/competition" >
</ImageView>




<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp" >

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="10dp">

<ImageButton
android:id="@+id/date"
android:layout_width="100dip"
android:layout_height="100dip"
android:layout_marginTop="26dp"
android:scaleType="fitXY"
android:src="@drawable/date" />

<ImageButton
android:id="@+id/mission"
android:layout_width="100dip"
android:layout_height="100dip"
android:layout_marginTop="26dp"
android:scaleType="fitXY"
android:src="@drawable/mission" />

<ImageButton
android:id="@+id/you"
android:layout_width="100dip"
android:layout_height="100dip"
android:layout_marginTop="26dp"
android:scaleType="fitXY"
android:src="@drawable/you" />

<ImageButton
android:id="@+id/competitionn"
android:layout_width="100dip"
android:layout_height="100dip"
android:layout_marginTop="26dp"
android:scaleType="fitXY"
android:src="@drawable/competition" />


</LinearLayout>
</HorizontalScrollView>

</LinearLayout>


rotate_in.xml:



<?xml version="1.0" encoding="utf-8"?>
<scale
xmlns:android="http://ift.tt/nIICcg"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="200"
android:fromXScale="0.0"
android:fromYScale="0.90"

android:pivotX="50%"
android:pivotY="50%"
android:startOffset="500"
android:toXScale="1.0"
android:toYScale="1.0" />


rotate_out.xml



<?xml version="1.0" encoding="utf-8"?>
<scale
xmlns:android="http://ift.tt/nIICcg"
android:duration="300"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.0"
android:toYScale="0.90" />


I use this to in the second activity overridePendingTransition(R.anim.rotate_in, R.anim.rotate_out);


The app works perfectly fine while using the fadein and fadeout animation. Please help.


No comments:

Post a Comment