0% found this document useful (0 votes)
16 views7 pages

Mad 32 Hs

The document describes an Android app development experiment implementing different layouts like linear, relative and absolute. It includes XML code for the different layouts and Java code to reference text views. The objective is to create a diverse and visually appealing user interface using different layout types.
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)
16 views7 pages

Mad 32 Hs

The document describes an Android app development experiment implementing different layouts like linear, relative and absolute. It includes XML code for the different layouts and Java code to reference text views. The objective is to create a diverse and visually appealing user interface using different layout types.
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/ 7

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

Experiment – 3.2

Student Name: Hardik Singh UID: 21BCS10108


Branch: BE-CSE-IT Section/Group: 906- A
Semester: 6th Date of Performance: 27/03/2024
Subject Name: MAD Lab Subject Code: 21CSH-355

Aim of the practical: Implement building blocks for Android Application using different
layouts such as linear, relative and absolute

Objective:-The objective of implementing building blocks for an Android application using


different layouts such as linear, relative, and absolute is to create a diverse and visually appealing user
interface that accommodates various design requirements. Different layout types offer flexibility in
organizing UI components, and understanding their usage is crucial for effective Android app
development.

1. CODE:
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="fill_parent"

android:layout_height="fill_parent"

tools:context=".MainActivity">

<!--Setting up TextViews-->

<TextView
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_x="100px"

android:layout_y="300px" />

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_x="120px"

android:layout_y="350px" />

</AbsoluteLayout>

<RelativeLayout

android:layout_width="fill_parent"

android:layout_height="fill_parent"

xmlns:android="http://schemas.android.com/apk/res/android">

<Button

android:id="@+id/button1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Top Left Button"

android:layout_alignParentLeft="true"

android:layout_alignParentTop="true"/>

<Button

android:id="@+id/button2"

android:layout_width="wrap_content"
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

android:layout_height="wrap_content"

android:text="Top Right Button"

android:layout_alignParentTop="true"

android:layout_alignParentRight="true"/>

<Button

android:id="@+id/button3"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Bottom Left Button"

android:layout_alignParentLeft="true"

android:layout_alignParentBottom="true"/>

android:id="@+id/button5"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="Middle Button"

android:layout_centerVertical="true"

android:layout_centerHorizontal="true"/>

</RelativeLayout>

Java Code:-

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

TextView heading, subHeading;


DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

// Referencing the TextViews

heading = (TextView) findViewById(R.id.heading);

subHeading = (TextView) findViewById(R.id.subHeading);

2. OUTPUT:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

3. Learning Outcomes:
 Successful USE of your Android development environment.
 Project Workspace.
 Configuration button Completion.
 How to add new layouts

You might also like