0% found this document useful (0 votes)
18 views4 pages

Practical 5-1

The document contains XML layouts for two Android UI implementations: a LinearLayout and an AbsoluteLayout. The LinearLayout includes multiple buttons arranged vertically and a horizontal LinearLayout containing additional buttons. The AbsoluteLayout features several views positioned at specific coordinates on the screen.

Uploaded by

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

Practical 5-1

The document contains XML layouts for two Android UI implementations: a LinearLayout and an AbsoluteLayout. The LinearLayout includes multiple buttons arranged vertically and a horizontal LinearLayout containing additional buttons. The AbsoluteLayout features several views positioned at specific coordinates on the screen.

Uploaded by

labadeshravani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

// Program to implement LinearLayout

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


<LinearLayout 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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical"
android:background="#000000"
android:layout_marginTop="20dp">

<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 1" />

<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 2" />

<Button
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 3" />

<Button
android:id="@+id/button4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 4" />

<Button
android:id="@+id/button5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 5" />

<Button
android:id="@+id/button6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 6" />
<Button
android:id="@+id/button7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 7" />

<Button
android:id="@+id/button8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 8" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>

<Button
android:id="@+id/button9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 9"
android:layout_marginLeft="3dp"/>

<Button
android:id="@+id/button10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 10"
android:layout_marginLeft="30dp"/>

<Button
android:id="@+id/button11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 11"
android:layout_marginLeft="30dp"/>

</LinearLayout>

</LinearLayout>
Output:

// Program to implement AbsoluteLayout

<?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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
tools:context=".MainActivity">

<View
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@color/green"
android:layout_x="0dp"
android:layout_y="0dp"/>

<View
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@color/green"
android:layout_x="150dp"
android:layout_y="150dp"/>

<View
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@color/green"
android:layout_x="300dp"
android:layout_y="300dp"/>

</AbsoluteLayout>

Output:

You might also like