How to developed animated splashscreen in android studio.

Dear Developer's.

Splash Screen of Android application is the 1st screen visible to the user for just 2 to 4 seconds. when the Android application launched. Then Splash Screen is the user’s first experience with the Android application. that’s why it is considered to be one of the most vital screens in the application. In splash screen to display some information about the company logo, About Application, company name, etc. We can also add some animations to the Splash screen as well. In this article, I will be making an animated Splash Screen Using JAVAA sample video Link (Animated spalshscreen for android application) is given below to get an idea about what we are going to do in this article. 



Create A new project:

To create a new project in Android Studio

Go to the File > New > NewProject> Empty Activity>Next


Now make a two files of activity
1. Java
2. xml

So Now Create anim folder. right click of mouse button. Go res> New> Directory


Now right click of mouse and create two resource files.
1. uptodown

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:duration="800"
android:fromYDelta="-100%p"
android:fromXDelta="0%p"/>
</set>

2. downtoup

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:toYDelta="0%p"
android:fromYDelta="100%p"
android:duration="800"/>
</set>

So now come to main java class and main xml file. Now first i will show you main xml file code.

1. activity_main

<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"
android:orientation="vertical"
android:background="@drawable/background"
tools:context=".MainActivity">

<LinearLayout
android:id="@+id/id_linearLayout_one"
android:layout_width="match_parent"
android:layout_height="400dp"
android:orientation="vertical"
android:layout_margin="10dp">

<TextView
android:textColor="@color/colorAccent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_title_main_page"
android:layout_gravity="center"
android:layout_marginTop="150dp"
android:textSize="40sp"
android:textStyle="bold" />

<TextView
android:textColor="@color/lightorangedark"
android:layout_width="398dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Download Movies Right Now"
android:textAlignment="center"
android:textSize="20sp"
android:layout_marginTop="50dp"/>

</LinearLayout>

<LinearLayout
android:id="@+id/id_linearLayout_two"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<Button
android:id="@+id/id_btn_next"
android:layout_width="170dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/buttonstyle"
android:text="Lets Start"
android:textAllCaps="false"
android:textColor="@color/lightorange"/>

</LinearLayout>

</LinearLayout>

After the file I will show you Java main class.

public class MainActivity extends AppCompatActivity {

LinearLayout linearLayout_one,linearLayout_two;
Button btn_next;
Animation uptodown,downtoup;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Remove Action Bar
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
setContentView(R.layout.activity_main);

btn_next = (Button)findViewById(R.id.id_btn_next);
linearLayout_one = (LinearLayout) findViewById(R.id.id_linearLayout_one);
linearLayout_two = (LinearLayout) findViewById(R.id.id_linearLayout_two);

uptodown = AnimationUtils.loadAnimation(this,R.anim.uptodown);
downtoup = AnimationUtils.loadAnimation(this,R.anim.downtoup);
linearLayout_one.setAnimation(uptodown);
linearLayout_two.setAnimation(downtoup);

// For auto play video ads, it's recommended to load the ad
// at least 30 seconds before it is shown
btn_next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

Intent intnt_home = new Intent(MainActivity.this, HomeActivity.class);
startActivity(intnt_home);

}
});

}

}


Post a Comment

Previous Post Next Post