0% found this document useful (0 votes)
62 views5 pages

Practical No 05

The document describes implementing a linear layout and absolute layout in Android. It includes XML code for an activity_main.xml file that contains several linear layouts to capture a user's name, age, and mobile number within edit texts and a submit button. It then provides modified XML code using an absolute layout instead to capture username and password within edit texts and a login button.

Uploaded by

Vaibhav Bhagwat
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)
62 views5 pages

Practical No 05

The document describes implementing a linear layout and absolute layout in Android. It includes XML code for an activity_main.xml file that contains several linear layouts to capture a user's name, age, and mobile number within edit texts and a submit button. It then provides modified XML code using an absolute layout instead to capture username and password within edit texts and a login button.

Uploaded by

Vaibhav Bhagwat
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
You are on page 1/ 5

Practical No: 5

 Develop a program to implement linear layout and absolute layout.

 activity_main.xml

<?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"
android:background="#3EB489"
tools:context=".MainActivity">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="50dp"
android:id="@+id/ll1">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/t1"
android:text="Name :"
android:textColor="#FF0000"
android:textSize="40sp"
android:textStyle="bold"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="35sp"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="50dp"
android:layout_below="@id/ll1"
android:id="@+id/ll2">

<TextView
android:id="@+id/t2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Age :"
android:textStyle="bold"
android:textColor="#FF0000"
android:textSize="40sp" />

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="35sp"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="50dp"
android:layout_below="@id/ll2"
android:id="@+id/ll3">

<TextView
android:id="@+id/t3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mobile No :"
android:textStyle="bold"
android:textColor="#FF0000"
android:textSize="40sp" />

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="35sp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="50dp"
android:layout_below="@id/ll3"
android:id="@+id/ll4">

<Button
android:layout_width="200dp"
android:layout_height="60dp"
android:layout_marginLeft="95dp"
android:text="Submit"
android:textSize="30sp"
android:textStyle="bold"
android:fontFamily="sans-serif-thin"
/>
</LinearLayout>
</RelativeLayout>
 Output:
 activity_main.xml
<?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:background="#3EB489"

tools:context=".MainActivity">

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="95dp"
android:layout_x="110dp"
android:layout_y="75dp"
android:text="!! Login !!"
android:textSize="35sp"
android:textStyle="italic|bold" />

<TextView
android:id="@+id/textView8"
android:layout_width="166dp"
android:layout_height="60dp"
android:layout_x="5dp"
android:layout_y="213dp"
android:text="Username : "
android:textColor="#FF0000"
android:textSize="30sp"
android:textStyle="bold"
/>
<TextView
android:id="@+id/textView9"
android:layout_width="165dp"
android:layout_height="60dp"
android:layout_x="5dp"
android:layout_y="296dp"
android:text="Password : "
android:textColor="#FF0000"
android:textSize="30sp"
android:textStyle="bold"/>

<EditText
android:layout_width="229dp"
android:layout_height="60dp"
android:layout_x="171dp"
android:layout_y="213dp" />
<EditText
android:layout_width="229dp"
android:layout_height="60dp"
android:layout_x="171dp"
android:layout_y="296dp" />

</AbsoluteLayout>
 Output:

You might also like