Instagram like login screen in Android

In this article, we are going to learn how to create awesome Instagram like Login screen in android.

In the below image you can see that what are we going to build.

Hope so you are interested to know how to make Instagram like Login screen, so now without wasting much time let’s start.

You can also refer our video tutorial for same.

So let’s start with this tutorial :

Instagram like login screen in Android

1. Create a new project in Android Studio by navigating to File ⇒ New ⇒ New Project and provide a name to your project. By default activity name is MainActivity.java.

2. Now open res => values => styles.xml file and paste the below code to change the color of the status bar.

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">#E6133C</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

</resources>

3. Now open MainActivity.java file and add the below line to hide the action bar in app.

package com.thecodingshef.loginuidemo;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

    }
}

4. Now create a new drawable res file by navigating res => drawable => New => Drawable resource file => insta_gradient.xml and put the below line of code in that file to make the gradient for Instagram like Login screen.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

     <gradient
         android:startColor="#B41044"
         android:endColor="#E61344"
         android:angle="90"
         />
</shape>

5. Now again create a new drawable res file by navigating res => drawable => New => Drawable resource file => login_btn_back.xml and put the below line of code in that file to make the background for Login button.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
   <solid
       android:color="#00D3D1D1"
       />
    <stroke
        android:color="#51FFFFFF"
        android:width="1dp"
        />
</shape>

6. Now to apply custom font, create a new resource directory by navigating res => New => Android Resource Directory and give the directory name as “font” and select “font” from resource type.

7. Now download this folder and copy all drawable resources from the drawable folder and paste all in res => drawable and copy all fonts from the font folder and paste in the font res => font.

8. Now Finally go to your activity_main.xml file to make the main user interface of Instagram like Login screen and paste the below lines of codes.

<?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:background="@drawable/insta_gradient"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
   <ImageView
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       app:layout_constraintTop_toTopOf="parent"
       android:id="@+id/image"
       android:src="@drawable/instagram"
       android:tint="#E9FFFFFF"
       app:layout_constraintLeft_toLeftOf="parent"
       app:layout_constraintRight_toRightOf="parent"
       android:layout_marginTop="80dp"
       />
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:text="Instagram"
        app:layout_constraintTop_toBottomOf="@+id/image"
        android:id="@+id/text"
        android:fontFamily="@font/roboto_bolditalic"
        android:textSize="35sp"
        android:textAlignment="center"
        android:textColor="#fff"
        />
    <EditText
        android:layout_width="350dp"
        android:layout_height="60dp"
        app:layout_constraintTop_toBottomOf="@+id/text"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        android:background="#27F0ECEC"
        android:padding="15dp"
        android:layout_marginTop="50dp"
        android:hint="Email"
        android:textSize="15sp"
        android:fontFamily="@font/roboto_regular"
        android:textColor="#fff"
        android:textColorHint="#B9FFFFFF"
        android:id="@+id/email"
        />
    <EditText
        android:layout_width="350dp"
        android:layout_height="60dp"
        app:layout_constraintTop_toBottomOf="@+id/email"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        android:background="#27F0ECEC"
        android:padding="15dp"
        android:textSize="15sp"
        android:layout_marginTop="15dp"
        android:hint="Password"
        android:fontFamily="@font/roboto_regular"
        android:textColor="#fff"
        android:textColorHint="#B9FFFFFF"
        android:id="@+id/password"
        />
    <TextView
        android:layout_width="350dp"
        android:layout_height="60dp"
        app:layout_constraintTop_toBottomOf="@+id/password"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginTop="20dp"
        android:text="Log in"
        android:id="@+id/btn"
        android:gravity="center"
        android:textSize="18sp"
        android:textAlignment="center"
        android:textColor="#54FFFFFF"
        android:padding="12dp"
        android:background="@drawable/login_btn_back"
        android:fontFamily="@font/roboto_regular"
        />
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toBottomOf="@+id/btn"
        android:text="@string/forget"
        android:textAlignment="center"
        android:layout_marginTop="30dp"
        android:textColor="#AEFFFFFF"
        android:id="@+id/forget"
        android:textSize="16sp"
        android:fontFamily="@font/roboto_regular"
        />
    <RelativeLayout
        android:layout_width="300dp"
        app:layout_constraintTop_toBottomOf="@+id/forget"
        android:layout_marginTop="30dp"
        android:id="@+id/layout"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_height="wrap_content">
        <View
            android:layout_width="130dp"
            android:layout_height="0.1dp"
            android:id="@+id/view1"
            android:layout_marginTop="10dp"
            android:background="#85FFFFFF"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="140dp"
            android:text="OR"
            android:fontFamily="@font/roboto_bold"
            android:textColor="#fff"
            android:textSize="15sp"
            />
        <View
            android:layout_width="130dp"
            android:layout_height="0.1dp"
            android:id="@+id/view2"
            android:layout_marginTop="10dp"
            android:background="#85FFFFFF"
            android:layout_alignParentRight="true"
            />
    </RelativeLayout>
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toBottomOf="@+id/layout"
        android:text="Log in with Facebook"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        android:drawableLeft="@drawable/facebook"
        android:drawablePadding="10dp"
        android:textSize="18sp"
        android:textColor="#F0FFFFFF"
        android:drawableTint="#fff"
        android:layout_marginTop="30dp"
        android:id="@+id/facebook"
        android:fontFamily="@font/roboto_bold"
        />
    <View
        android:layout_width="match_parent"
        android:layout_height="0.1dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="60dp"
        android:background="#4DFFFFFF"
        />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="60dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:text="@string/signup"
        android:textAlignment="center"
        android:textSize="16sp"
        android:gravity="center"
        android:background="#0FF0ECEC"
        android:fontFamily="@font/roboto_regular"
        android:textColor="#B7FFFFFF"
        />
</androidx.constraintlayout.widget.ConstraintLayout>

9. Finally, run the app and you will get the output as shown in demo image.

If you found this post useful, don’t forget to share this with your friends, and if you have any query feel free to comment it in the comment section.

Thank you 🙂 Keep Learning !

Leave a Comment

Your email address will not be published. Required fields are marked *