how to make Splash Screen with an animation and whitout an animation In android App
Splash Screen is most commonly the first startup screen which appears when App is opened. In other words, it is a simple constant screen for a fixed amount of time which is used to display the company logo, name, advertising content, etc.
now create the first layout file in our project.
<?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:orientation="vertical"
android:layout_gravity="center"
android:gravity="center"
android:layout_height="match_parent"
tools:context=".splaceschreen">
<ImageView
android:gravity="center"
android:src="@drawable/logo"
android:id="@+id/splacimag"
android:layout_width="100dp"
android:layout_height="100dp"/>
</LinearLayout>
now create java file in android project
package com.vivid.myshop;
import androidx.appcompat.app.AppCompatActivity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import com.vivid.myshop.customerdetial.costumerlogin;
public class splaceschreen extends Activity {
private ImageView img;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splaceschreen);
img = (ImageView)findViewById(R.id.splacimag);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// This method will be executed once the timer is over
Intent i = new Intent(splaceschreen.this, costumerlogin.class);
startActivity(i);
finish();
}
}, 2000);
}
}
2: with an animation splash screen
package com.vivid.myshop;
import androidx.appcompat.app.AppCompatActivity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import com.vivid.myshop.customerdetial.costumerlogin;
public class splaceschreen extends Activity {
private ImageView img;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splaceschreen);
img = (ImageView)findViewById(R.id.splacimag);
Animation animZoomIn = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.zoom_out);
img.startAnimation(animZoomIn);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// This method will be executed once the timer is over
Intent i = new Intent(splaceschreen.this, costumerlogin.class);
startActivity(i);
finish();
}
}, 2000);
}
}
Comments
Post a Comment