Practical No - 6,7

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

“Login Form Using Absolute Layout”

<? xml version="1.0" encoding="utf-8" ?>


<AbsoluteLayout 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:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="30dp"
android:layout_y="50dp"
android:text="Username : "/>

<EditText
android:layout_width="90sp"
android:layout_height="30dp"
android:layout_x="120dp"
android:layout_y="50dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="30dp"
android:layout_y="90dp"
android:text="Password : "/>

<EditText
android:layout_width="90sp"
android:layout_height="30dp"
android:layout_x="120dp"
android:layout_y="90dp"/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"
android:layout_x="70dp"
android:layout_y="120dp"/>

</AbsoluteLayout>
“Login Form Using Linear Layout”
<? xml version="1.0" encoding="utf-8"? >
<FrameLayout 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:layout_height="match_parent"
tools:context=".MainActivity"
android:background="@drawable/bg">

<!-- Login Form -->


<LinearLayout
android:id="@+id/loginForm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="20dp"
android:orientation="vertical">

<!-- Username -->


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

<!-- Password -->


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

<!-- Login Button -->


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

</FrameLayout>
“Login Form Using TableLayout”
<? xml version="1.0" encoding="utf-8" ?>
<TableLayout 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:layout_height="match_parent"
tools:context=".MainActivity">

<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Username : "
android:padding="5dp"/>

<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp"/>

</TableRow>

<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Password : "
android:padding="5dp"/>

<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp"/>

</TableRow>

<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"
android:padding="5dp"/>

</TableRow>

</TableLayout>

“Login Form Using Relative Layout”


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_height="match_parent"
tools:context=".MainActivity"
android:background="@drawable/bg">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
android:textSize="30sp"
android:textStyle="bold"
android:layout_marginTop="100sp"
android:layout_centerHorizontal="true"
android:textColor="@color/white"
android:id="@+id/sign"
/>

<EditText
android:id="@+id/user"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/sign"
android:layout_marginStart="10sp"
android:layout_marginTop="10sp"
android:layout_marginEnd="10sp"
android:layout_marginBottom="10sp"
android:background="#30FFFFFF"
android:hint="USERNAME"
android:padding="10sp"
android:textColorHint="@color/white">
</EditText>

<EditText
android:id="@+id/pass"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/user"
android:layout_marginStart="10sp"
android:layout_marginTop="10sp"
android:layout_marginEnd="10sp"
android:layout_marginBottom="10sp"
android:background="#30FFFFFF"
android:hint="PASSWORD"
android:padding="10sp"
android:textColorHint="@color/white">

</EditText>

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/pass"
android:layout_marginTop="25sp"
android:text="Login"
android:textSize="20sp"/>

</RelativeLayout>

You might also like