This tutorial shows you how to create beautiful login and signup screens in android.

1. Creating new Android Studio Project.

2. Open style.xml and copy below code.


 

 

3. Open colors.xml and copy below code.



    #263238
    #263238
    #FFFFFF
    #FFFFFF
    #000000
    #6BD7A9

4.Open AndroidManifest.xml and apply theme.


5.Create 3 shape file in drawable folder.

buttonshape.xml


edittextshape.xml


edittextshapeerror.xml


6. Open activity_main.xml and replace with below code.




    

        
        

        
        

        
        

        
        

        
        

        
        

    

7. In case of error apply edittextshapeerror to EdittextBox.

In ActivityMain.java on Login Button click event.

public void Login(View view)
{
    editTextEmail =(EditText)findViewById(R.id.login_email);
    editTextPassword =(EditText)findViewById(R.id.login_password);

    String str_email= editTextEmail.getText().toString();
    String str_password= editTextPassword.getText().toString();

    if(validateLogin(str_email,str_password))
    {
        setSharedPreferences();

        Intent i = new Intent(getApplicationContext(),MainActivity.class);
        startActivity(i);
    }
    else {
        editTextEmail.setBackground(getDrawable(R.drawable.edittextshapeerror));
        editTextPassword.setBackground(getDrawable(R.drawable.edittextshapeerror));
        Toast.makeText(getApplicationContext(),"Wrong credential",Toast.LENGTH_SHORT).show();
    }
}
public boolean validateLogin(String email,String password)
{
    //your validation code
}

8. Add image in drawable.

logo.png

logo

Leave a comment