Tuesday, January 7, 2020

1. SplashScreen Design in android studio for my project.


First of all I started with the Splash Screen Activity, I thought its look pretty good for user who like to start well.

So simply i took Imageview for that I already created my own logo:-

Then in xml file my code was look like.

activity_splash.xml
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   
xmlns:tools="http://schemas.android.com/tools"
   
android:layout_width="match_parent"
   
android:layout_height="match_parent"
   
android:background="@color/colorPrimary"
   
android:orientation="vertical"
   
tools:context=".SplashActivity">

    <
ImageView
       
android:id="@+id/splash"
       
android:layout_width="250dp"
       
android:layout_height="match_parent"
       
android:layout_gravity="center"
       
android:layout_marginLeft="10dp"
       
android:layout_marginRight="10dp"
       
android:paddingLeft="10dp"
       
android:paddingTop="10dp"
       
android:paddingRight="10dp"
       
android:paddingBottom="10dp"
        
android:src="@drawable/qweqweqwe" />

</
LinearLayout>

In imageview all are the same field that we use regular In our android projects,

After it I coded for my java file lets see what I need to write for having splash screen.

SplashActivity.java
package milan.com.sampledesign;

  
  import android.content.Intent;
  import android.os.Bundle;
  import android.os.Handler;
  import androidx.appcompat.app.AppCompatActivity;
  
  public class SplashActivity extends AppCompatActivity {

    Handler handler;


    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);
  

        handler = new Handler();

        handler.postDelayed(new Runnable() {

            @Override

            public void run() {

                Intent splash = new Intent(MainActivity.this, Login_activity.class);

                startActivity(splash);
            }

        }, 3000);
    }
}
Explanations for java file of splashactivity.

I took Handler class because handler class allow user to send and process message so in declaration section I declare “Handler” and its object “handler”,

After I casted in initialization section that “ handler =new Handler(); ” and I wrote second line post delayed means user need to wait for that much time that we specified on our project and for that I wrote “handler.postdelayed(new Runnable)” now this runnable means its started again its process.

So I simply put link in that method look how.
Intent splash = new Intent(SplashActivity.this,LoginActivity.class);
Startactivity(splash);
//finish();

So I put intent in which I define source and destination, after it I said to start my activity.

Next my activity will be login activity you will get the post of login screen is to as early as possible.

First Post

Hello friends,