Professional Documents
Culture Documents
Animation Zoom in and Out
Animation Zoom in and Out
Xml code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageView
android:id="@+id/imageView"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_launcher_foreground"
android:scaleType="fitCenter"
android:clickable="true"
android:onClick="zoomIn" />
</LinearLayout>
Mainactivity.java
package com.example.animapp;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
Scale_up.xml
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="1.5"
android:toYScale="1.5"
android:duration="500"
android:pivotX="50%"
android:pivotY="50%"
android:fillAfter="false" />
Scale_down.xml
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXScale="1.5"
android:fromYScale="1.5"
android:toXScale="1.0"
android:toYScale="1.0"
android:duration="500"
android:pivotX="50%"
android:pivotY="50%"
android:fillAfter="false" />