0% found this document useful (0 votes)
37 views9 pages

EX 25

The document outlines a program that implements image manipulation features such as rotation, zooming, and fading using a graphical user interface (GUI) in Android. It includes XML layout definitions for buttons and image views, as well as Java code for handling animations. Various animation resources are defined for different effects like clockwise rotation, fading, and zooming in and out.

Uploaded by

Omkar Mankar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views9 pages

EX 25

The document outlines a program that implements image manipulation features such as rotation, zooming, and fading using a graphical user interface (GUI) in Android. It includes XML layout definitions for buttons and image views, as well as Java code for handling animations. Various animation resources are defined for different effects like clockwise rotation, fading, and zooming in and out.

Uploaded by

Omkar Mankar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

X.

Exercise
1. Write a program to rotate the image in clockwise/anticlockwise, Zoom IN/Zoom OUT, Fade IN/Fade
OUT by using the following GUI.

activity_main.xml android:layout_alignRight="@+id/textView"
android:layout_marginStart="-111dp"
<?xml version="1.0" encoding="utf-8"?> android:layout_marginLeft="-111dp"
<RelativeLayout android:layout_marginTop="11dp"
xmlns:android="http://schemas.android.com/apk/r
android:layout_marginEnd="-111dp"
es/android"
android:layout_marginRight="-111dp"
xmlns:app="http://schemas.android.com/apk/res-
auto" app:srcCompat="@mipmap/umbrella_foreground
"
xmlns:tools="http://schemas.android.com/tools"
android:onClick="asd"/>
android:layout_width="match_parent"
android:layout_height="match_parent"
<Button
tools:context=".MainActivity">
android:id="@+id/button"
android:layout_width="120dp"
<TextView
android:layout_height="wrap_content"
android:id="@+id/textView"
android:layout_alignParentStart="true"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentTop="true"
android:layout_marginStart="2dp"
android:layout_centerHorizontal="true"
android:layout_marginLeft="2dp"
android:text="ANIMATION"
android:layout_marginTop="470dp"
android:textSize="35dp" />
android:onClick="zoom"
android:text="zoom" />
<ImageView
android:id="@+id/imageView"
<Button
android:layout_width="410dp"
android:layout_width="120dp"
android:layout_height="428dp"
android:layout_height="wrap_content"
android:layout_below="@+id/textView"
android:text="clockwise"
android:layout_alignStart="@+id/textView"
android:id="@+id/button2"
android:layout_alignLeft="@+id/textView"
android:layout_alignTop="@+id/button"
android:layout_alignEnd="@+id/textView"
android:layout_centerHorizontal="true"
android:onClick="clockwise"/> <Button
<Button android:id="@+id/button6"
android:id="@+id/button3" android:layout_width="120dp"
android:layout_width="120dp" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:layout_below="@+id/button3"
android:layout_alignTop="@+id/button2" android:layout_alignLeft="@+id/button3"
android:layout_alignParentRight="true" android:layout_marginLeft="2dp"
android:onClick="fade" android:layout_marginTop="0dp"
android:text="fade" /> android:layout_toRightOf="@+id/textView"
android:text="slide" />
<Button
android:id="@+id/button4" <Button
android:layout_width="120dp" android:id="@+id/button8"
android:layout_height="wrap_content" android:layout_width="120dp"
android:layout_below="@+id/button7" android:layout_height="wrap_content"
android:layout_alignParentStart="true" android:layout_below="@+id/button5"
android:layout_alignParentLeft="true" android:layout_alignLeft="@+id/button2"
android:layout_marginStart="2dp" android:layout_toRightOf="@+id/button7"
android:layout_marginLeft="2dp" android:onClick="fadeout"
android:layout_marginTop="5dp" android:text="fade out" />
android:onClick="blink" <Button
android:text="blink" /> android:layout_width="120dp"
android:layout_height="wrap_content"
<Button android:text="Rotate"
android:layout_width="120dp" android:onClick="rotate"
android:layout_height="wrap_content" android:id="@+id/button9"
android:text="move" android:layout_alignLeft="@+id/button6"
android:onClick="move" android:layout_below="@+id/button6"
android:id="@+id/button5" android:layout_toRightOf="@+id/button8"
android:layout_below="@+id/button2" />
android:layout_alignRight="@+id/button2"
android:layout_alignEnd="@+id/button2" <Button
android:layout_alignLeft="@+id/button2" android:id="@+id/button7"
android:layout_alignStart="@+id/button2" /> android:layout_width="120dp"
android:layout_height="wrap_content" @Override
android:layout_below="@+id/button" protected void onCreate(Bundle
savedInstanceState) {
android:layout_marginStart="2dp"
super.onCreate(savedInstanceState);
android:layout_marginLeft="2dp"
setContentView(R.layout.activity_main);
android:layout_marginTop="-2dp"
}
android:onClick="ZoomOut"
public void clockwise(View view)
android:text="Zoom out" />
{
ImageView image =
<Button
(ImageView)findViewById(R.id.imageView);
android:id="@+id/button10"
Animation animation =
android:layout_width="wrap_content" AnimationUtils.loadAnimation(getApplicationCo
ntext(),
android:layout_height="wrap_content"
R.anim.clockwise);
android:layout_below="@+id/button8"
image.startAnimation(animation);
android:layout_marginStart="110dp"
}
android:layout_marginTop="6dp"
public void zoom(View view)
android:onClick="anticlockwise"
{
android:text="Anticlockwise" />
ImageView image =
</RelativeLayout> (ImageView)findViewById(R.id.imageView);
Animation animation1 =
MainActivity.java AnimationUtils.loadAnimation(getApplicationCo
ntext(),
package com.example.ex2501;
R.anim.zoom);
image.startAnimation(animation1);
import
androidx.appcompat.app.AppCompatActivity; }
public void fade(View view)

import android.view.View; {

import android.view.animation.Animation; ImageView image =


(ImageView)findViewById(R.id.imageView);
import android.view.animation.AnimationUtils;
Animation animation1 =
import android.widget.ImageView; AnimationUtils.loadAnimation(getApplicationCo
import android.os.Bundle; ntext(),
R.anim.fade);

public class MainActivity extends image.startAnimation(animation1);


AppCompatActivity { }
public void blink(View view)
{ public void fadeout(View view)
ImageView image = {
(ImageView)findViewById(R.id.imageView);
ImageView image =
Animation animation1 = (ImageView)findViewById(R.id.imageView);
AnimationUtils.loadAnimation(getApplicationCo
Animation animation1 =
ntext(),
AnimationUtils.loadAnimation(getApplicationCo
R.anim.blink); ntext(),
image.startAnimation(animation1); R.anim.fadeout);
} image.startAnimation(animation1);
public void move(View view) }
{ public void rotate(View view)
ImageView image = {
(ImageView)findViewById(R.id.imageView);
ImageView image =
Animation animation1 = (ImageView)findViewById(R.id.imageView);
AnimationUtils.loadAnimation(getApplicationCo
Animation animation1 =
ntext(),
AnimationUtils.loadAnimation(getApplicationCo
R.anim.move); ntext(),
image.startAnimation(animation1); R.anim.rotate);
} image.startAnimation(animation1);
public void slide(View view) }
{ public void anticlockwise(View view)
ImageView image = {
(ImageView)findViewById(R.id.imageView);
ImageView image =
Animation animation1 = (ImageView)findViewById(R.id.imageView);
AnimationUtils.loadAnimation(getApplicationCo
Animation animation1 =
ntext(),
AnimationUtils.loadAnimation(getApplicationCo
R.anim.slide); ntext(),
image.startAnimation(animation1); R.anim.anticlockwise);
} image.startAnimation(animation1);
public void ZoomOut(View view){
ImageView image = }
(ImageView)findViewById(R.id.imageView);
Animation animation1 =
}
AnimationUtils.loadAnimation(getApplicationCo
ntext(),
R.anim.zoomout);
image.startAnimation(animation1);
}
res/anim/anticlockwise.xml <rotate
xmlns:android="http://schemas.android.com/apk/r
es/android"
<?xml version="1.0" encoding="utf-8"?>
android:fromDegrees="0"
<set
android:toDegrees="360"
xmlns:android="http://schemas.android.com/apk/r
es/android" android:pivotX="50%"
android:interpolator="@android:anim/cycle_inter android:pivotY="50%"
polator">
android:duration="5000" >
<rotate android:fromDegrees="360"
</rotate>
android:toDegrees="0"
<rotate
android:pivotX="50%" xmlns:android="http://schemas.android.com/apk/r
es/android"
android:pivotY="50%"
android:startOffset="5000"
android:duration="5000" />
android:fromDegrees="360"
</set>
android:toDegrees="0"
android:pivotX="50%"
res/anim/blink.xml
android:pivotY="50%"
android:duration="5000" >
<?xml version="1.0" encoding="utf-8"?>
</rotate>
<set
xmlns:android="http://schemas.android.com/apk/r </set>
es/android">
<alpha android:fromAlpha="0.0"
res/anim/fade.xml
android:toAlpha="1.0"

<?xml version="1.0" encoding="utf-8"?>


android:interpolator="@android:anim/accelerate_i
nterpolator" <set
xmlns:android="http://schemas.android.com/apk/r
android:duration="600"
es/android"
android:repeatMode="reverse"
android:repeatCount="infinite"/> android:interpolator="@android:anim/accelerate_i
nterpolator" >
</set>
<alpha
android:fromAlpha="0"
res/anim/clockwise.xml
android:toAlpha="1"
android:duration="2000" >
<?xml version="1.0" encoding="utf-8"?>
</alpha>
<set
xmlns:android="http://schemas.android.com/apk/r
es/android">
<alpha <translate
android:startOffset="2000" android:fromXDelta="0%p"
android:fromAlpha="1" android:toXDelta="75%p"
android:toAlpha="0" android:duration="800" />
android:duration="2000"> </set>
</alpha>
</set> res/anim/rotate.xml

res/anim/fadeout.xml <?xml version="1.0" encoding="utf-8"?>


<rotate
<?xml version="1.0" encoding="utf-8"?>
xmlns:android="http://schemas.android.com/apk/r
<set
es/android"
xmlns:android="http://schemas.android.com/apk/r
es/android" android:fromDegrees="0"
android:toDegrees="360"
android:interpolator="@android:anim/linear_inter
android:pivotX="50%"
polator">
android:pivotY="50%"
<alpha
android:repeatCount="infinite"
android:duration="2000"
android:duration="1200" />
android:fromAlpha="1.0"
android:toAlpha="0.1" >
res/anim/slide.xml
</alpha>
</set>
<?xml version="1.0" encoding="utf-8"?>
<set
res/anim/move.xml
xmlns:android="http://schemas.android.com/apk/r
es/android"
<?xml version="1.0" encoding="utf-8"?> android:fillAfter="true" >
<set <scale
android:duration="500"
xmlns:android="http://schemas.android.com/apk/r
android:fromXScale="1.0"
es/android"
android:fromYScale="1.0"
android:interpolator="@android:anim/linear_inter
polator" android:interpolator="@android:anim/linear_inter
polator"
android:fillAfter="true">
android:toXScale="1.0"
android:toYScale="0.0" /> res/anim/zoomout.xml
</set>
<?xml version="1.0" encoding="utf-8"?>
res/anim/zoom.xml <scale
xmlns:android="http://schemas.android.com/apk/r
es/android"
<?xml version="1.0" encoding="utf-8"?>
android:fromXScale="5"
<set
android:toXScale="1"
xmlns:android="http://schemas.android.com/apk/r
es/android"> android:fromYScale="5"
<scale android:toYScale="1"
xmlns:android="http://schemas.android.com/apk/r
android:pivotX="50%"
es/android"
android:pivotY="50%"
android:fromXScale="0.5"
android:duration="1000"
android:toXScale="3.0"
android:fillAfter="true">
android:fromYScale="0.5"
</scale>
android:toYScale="3.0"
android:duration="5000"
android:pivotX="50%"
android:pivotY="50%" >
</scale>
<scale
xmlns:android="http://schemas.android.com/apk/r
es/android"
android:startOffset="5000"
android:fromXScale="3.0"
android:toXScale="0.5"
android:fromYScale="3.0"
android:toYScale="0.5"
android:duration="5000"
android:pivotX="50%"
android:pivotY="50%" >
</scale>
</set>
Output:

You might also like