Animated Splash Screen - Zoom out to Circle in Android Studio
A beautiful UI is essential for any app or game. In this article we will create a animated splash screen. We are using zoom out animation which is created by xml code. We will create this animation
Below is the code for this animation
Codes:
res/drawable/circle.xml -
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid
android:color="@color/Blue"/>
<size
android:width="100dp"
android:height="100dp"/>
<corners
android:radius="200dp"/>
</shape>
res/anim/zoom.xml -
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="2000"
android:pivotX="50%"
android:pivotY="50%"
android:fromYScale="200%p"
android:toYScale="1"
android:fromXScale="350%p"
android:toXScale="1"/>
</set>
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:background="@color/lightBlue"
tools:context=".MainActivity">
<ImageView
android:id="@+id/image"
android:layout_width="150dp"
android:layout_height="150dp"
android:background="@drawable/circle"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"
android:textColor="@color/white"
android:textSize="60dp"
android:fontFamily="cursive"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
activity_main2.xml -
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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=".Main2Activity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="60dp"
android:text="Wellcome"
android:textColor="@color/Blue"
android:textStyle="bold"
android:fontFamily="cursive"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
MainActivity.java -
package com.example.test;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
Animation zoom;
ImageView img;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
zoom = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.zoom);
img = findViewById(R.id.image);
img.startAnimation(zoom);
Handler h = new Handler();
h.postDelayed(new Runnable() {
@Override
public void run() {
Intent i = new Intent(getApplicationContext(),Main2Activity.class);
startActivity(i);
finish();
}
},4000);
}
}
YouTube video link
No comments:
Post a Comment