Login Screen - Form

Here we will design a Login Screen. Normally this consists of User Name or Email and Password EditText and a Login Button. Note that In the code the resources used in XML code is the local resource of author. User must need to place the resources with same name or change name of it in code. Resources includes drawable images, color and strings.




<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="@drawable/bg"
  android:orientation="vertical">

  <ImageButton
      android:id="@+id/user_profile_photo"
      android:layout_width="100dp"
      android:layout_height="100dp"
      android:layout_above="@+id/lay_bg"
      android:layout_centerHorizontal="true"
      android:layout_marginBottom="16dp"
      android:background="@drawable/ustb_logo"
      android:elevation="4dp" />

  <RelativeLayout
      android:id="@+id/lay_bg"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true"
      android:layout_marginLeft="30dp"
      android:layout_marginRight="30dp"
      android:background="#FFFFFF"
      android:elevation="4dp"
      android:orientation="vertical"
      android:padding="20dp">

      <LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical"
          android:paddingTop="30dp">

          <android.support.design.widget.TextInputLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content">

              <EditText
                  android:id="@+id/user"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:drawableLeft="@drawable/icon_user"
                  android:hint="User Name"
                  android:inputType="textEmailAddress"
                  android:singleLine="true"
                  android:textColor="#FFFFFF" />
          </android.support.design.widget.TextInputLayout>

          <android.support.design.widget.TextInputLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content">

              <EditText
                  android:id="@+id/passowrd"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="16dp"
                  android:drawableLeft="@drawable/icon_lock"
                  android:hint="Password"
                  android:inputType="textPassword"
                  android:singleLine="true"
                  android:textColor="#FFFFFF" />
          </android.support.design.widget.TextInputLayout>

          <Button
              android:id="@+id/login"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:layout_margin="22dp"
              android:background="#4270ae"
              android:padding="10dp"
              android:text="Sign in"
              android:textColor="#000000"
              android:textSize="18sp" />
      </LinearLayout>
  </RelativeLayout>

</RelativeLayout>

Comments