0% found this document useful (0 votes)
5 views8 pages

Android Login Form Layouts Guide

The document contains five different XML layouts for a login form in Android, each using a different layout type: LinearLayout, AbsoluteLayout, FrameLayout, TableLayout, and RelativeLayout. Each layout includes a TextView for the title, two EditTexts for username and password, and a Button for login. The layouts vary in structure and positioning of elements, demonstrating different approaches to creating a user interface.

Uploaded by

Apurva Chaudhari
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views8 pages

Android Login Form Layouts Guide

The document contains five different XML layouts for a login form in Android, each using a different layout type: LinearLayout, AbsoluteLayout, FrameLayout, TableLayout, and RelativeLayout. Each layout includes a TextView for the title, two EditTexts for username and password, and a Button for login. The layouts vary in structure and positioning of elements, demonstrating different approaches to creating a user interface.

Uploaded by

Apurva Chaudhari
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1.

Login Form using LinearLayout


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="[Link]
xmlns:tools="[Link]
tools:context=".MainActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">

<TextView
android:id="@+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login Form"
android:textSize="24sp"
android:textStyle="bold"
android:layout_gravity="center"/>

<EditText
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Username"/>

<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword"/>

<Button
android:id="@+id/loginbtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Login"/>
</LinearLayout>

2. Login Form using AbsoluteLayout


<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="[Link]
xmlns:tools="[Link]
tools:context=".MainActivity"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="120dp"
android:layout_y="100dp"
android:text="Login Form"
android:textSize="24sp"
android:textStyle="bold"/>

<EditText
android:id="@+id/username"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_x="100dp"
android:layout_y="150dp"
android:hint="Username"/>

<EditText
android:id="@+id/password"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_x="100dp"
android:layout_y="200dp"
android:hint="Password"
android:inputType="textPassword"/>

<Button
android:id="@+id/loginbtn"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_x="100dp"
android:layout_y="250dp"
android:text="Login"/>
</AbsoluteLayout>

3. Login Form using FrameLayout and LinearLayout


<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="[Link]
xmlns:tools="[Link]
tools:context=".MainActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center">

<TextView
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Login Form"
android:textSize="24sp"
android:textStyle="bold"
android:gravity="center"/>

<EditText
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Username"/>

<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword"/>

<Button
android:id="@+id/loginbtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Login"/>
</LinearLayout>
</FrameLayout>

4. Login Form using TableLayout


<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="[Link]
xmlns:tools="[Link]
tools:context=".MainActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:stretchColumns="1">

<TableRow>
<TextView
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Login Form"
android:textSize="24sp"
android:textStyle="bold"
android:gravity="center"
android:layout_span="2"/>
</TableRow>

<TableRow>
<EditText
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Username"
android:layout_span="2"/>
</TableRow>

<TableRow>
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword"
android:layout_span="2"/>
</TableRow>

<TableRow>
<Button
android:id="@+id/loginbtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Login"
android:layout_span="2"/>
</TableRow>
</TableLayout>

5. Login Form using RelativeLayout


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="[Link]
xmlns:tools="[Link]
tools:context=".MainActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">

<TextView
android:id="@+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login Form"
android:textSize="24sp"
android:textStyle="bold"
android:layout_centerHorizontal="true"
android:layout_marginTop="80dp"/>

<EditText
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Username"
android:layout_marginTop="30dp"
android:layout_below="@id/login"/>

<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword"
android:marginTop="15dp"
android:layout_below="@id/username"/>

<Button
android:id="@+id/loginbtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Login"
android:layout_marginTop="15dp"
android:layout_below="@id/password"/>
</RelativeLayout>

You might also like