How to make a login and sign up screen using android studio


Today every app needs Login and SignUp page. So today we are going to learn how to create awesome Login and SignUp screen. There are certain functionalities that i had included in this app also that are listed below:
NOTE:The script is in eclipse format so import the script as Eclipse project in Android Studio. It will run.
  1. Custom Toast Alert when any error occurred.
  2. Shake Animation when fields are empty. (Login Only)
  3. Show/Hide Password. (Login Only)
  4. Screen Animation.

video tutorial


 So let’s start with this tutorial :

1. Create a new project in Android Studio by navigating to File ⇒ New Android ⇒ Application Project and fill required details. By default my activity is MainActivity.java.
2. Open res ⇒ values ⇒ strings.xml and add below string values. This are the strings that i am going to use in this tutorial.
3. Open res ⇒ values and create new xml file naming colors.xml for placing all the colors at one place to use it anytime.
4. Now create activity_main.xml file that contains an ImageView that close activity on press and a FrameLayout for placing fragments.
We will here work on fragments so if you don’t know how to use fragments then you can check my tutorial about Android Fragments.
5. Now create a new drawable directory under res folder and under this directory create drawable selector.
  • Button Selector
  • TextView Selector
We have to use this selector for Buttons and TextViews. 6. Create new xml file for Login screen naming login_layout.xml and add the following lines.
7. Create new xml file for SignUp screen naming signup_layout.xml and add the following lines.
8. Create  new xml file for ForgorPassword screen naming forgotpassword_layout.xml and add the following lines.
9. Now create a Utils.java file that contains some global strings for email validation and fragment tags.
10. Since i am using Custom Toast for displaying error so for this we need a custom xml file under layout directory. So create a new xml file naming custom_toast.xml that contains a TextView for displaying error.
11. Now create java file for Custom Toast naming CustomToast.java and add the following code. If you don’t know how to implement custom toast then you can read me tutorial about Custom Toast.
12. And also i am giving shake animation and fragment animation and for that we need to create new directory under res directory naming anim and under this directory create animation files. Below are certain animations that i am going to use in this app:
  • Left Enter Animation
  • Left Exit Animation
  • Right Enter Animation
  • Right Exit Animation
  • Cycle Animation
  • Shake Animation (x-axis)
You can learn how to use Animation in android from upcoming Animation Tutorials. We will use all above animations in our app. 13. Now create a java class for Login naming Login_Fragment.java and add the following code.
14. Now create a java class for SignUp naming SignUp_Fragment.java and add the following code.
15. Now create a java class for ForgotPassword naming ForgotPassword_Fragment.java and add the following code.
16. Finally, run the app and you will get the output as shown in video. You can use this code for your app by making slightly changes or as it is.
Thanks.

Comments