ad728

Thursday, December 14, 2017

AIDE Tutorial - 44 Rotate Animation

AIDE Tutorial - 44 Rotate Animation

Watch the Video Below

MainActivity.Java
package com.kcgroup.animrotate;
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.view.animation.*;
public class MainActivity extends Activity
{ @Override

    protected void onCreate(Bundle savedInstanceState)    {        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);    }
public void cw(View v){ImageView image=(ImageView)findViewById(R.id.mainImageView);
Animation an=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.rotate_clockwise);
image.startAnimation(an);}
public void ccw(View v){ImageView image=(ImageView)findViewById(R.id.mainImageView);
Animation an=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.rotate_countercw);image.startAnimation(an);}}
Main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
   android:orientation="vertical" >
    <ImageView
android:layout_weight="4"
android:id="@+id/mainImageView"
        android:src="@drawable/ic_launcher"
        android:layout_width="match_parent"      android:layout_height="wrap_content" />
<Button
android:onClick="cw"
android:text="Clock Wise"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:onClick="ccw"
android:text="Counter Clock wise"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
Rotate_clockwise.xml
<?xml version="1.0" encoding="utf-8"?>
<setxmlns:android="http://schemas.android.com/apk/res/android"
>
<rotate
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="1000"
android:repeatCount="2"
android:interpolator="@android:anim/cycle_interpolator"/></set>
Rotate_CounterClockWise.xml
<?xml version="1.0" encoding="utf-8"?>
<setxmlns:android="http://schemas.android.com/apk/res/android"
>
<rotate
android:fromDegrees="360"
android:toDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="1000"
android:repeatCount="2"
android:interpolator="@android:anim/cycle_interpolator"/></set>
Share:

0 comments:

Post a Comment

Total Pageviews

Sponsor

Sponsor

ad300

Blog Archive