free web tracker
Course Content
Java Programming Basics for Android
Learn the basics of Java programming for Android app development using Android Studio. This guide covers key concepts like variables, loops, and classes to help you start building your first Android apps with confidence. Perfect for beginners!
0/10
User Interaction and App Logic
Learn how to make your app respond to users! This section covers handling clicks, getting input, showing messages, switching screens, and saving simple data. A perfect start to build interactive Android apps with real logic.
0/10
Advanced Layouts and Components
Learn to build modern Android UIs using advanced layouts like RecyclerView, CardView, TabLayout, and more. This section helps beginners create beautiful, interactive, and user-friendly app interfaces step by step.
0/10
Media and Resources
Learn how to manage media and resources in Android Studio. This section covers adding audio, images, video, using drawables, custom fonts, and handling runtime permissions—essential for building rich, engaging Android applications.
0/4
Mastering Java Android Development – Beginner

Animations in Android help create a smooth, engaging user experience. In this guide, you’ll learn how to add simple animations (like fade in, scale, translate, rotate) using Java in Android Studio.

Step 1: Design Layout

Edit your activity_main.xml to include a view to animate (e.g., ImageView or Button):

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:id="@+id/myImage"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:src="@drawable/ic_launcher_foreground"
        android:layout_centerInParent="true"/>
</RelativeLayout>

Step 2: Create Animation XML

    1. Right-click on res > New > Android Resource Directory.
    2. Set Resource type to anim.
    3. Inside res/anim, create a new XML file like fade_in.xml:

  1.  

  1.  

<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:fromAlpha="0.0"
    android:toAlpha="1.0" />

You can create other animations:

    • rotate.xml
    • scale.xml
    • translate.xml

Step 3: Apply Animation in Java

Open MainActivity.java and add:

import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    ImageView myImage;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        myImage = findViewById(R.id.myImage);

        // Load the animation
        Animation fadeIn = AnimationUtils.loadAnimation(this, R.anim.fade_in);
        
        // Start the animation
        myImage.startAnimation(fadeIn);
    }
}

Tips

    • Place animation logic inside a button click or activity transition for better interactivity.
    • Use AnimationListener to listen for animation start/end.

Output

The image will fade in when the app starts.