Practical No. 5: Develop A Program To Implement Linear Layout and Absolute Layout

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

Name : Shweta Bhargude.

Date of Performance : 23/02/2022


Roll No : 56 Div : TYCO A. Date of Submission : 03/03/2022

Practical No. 5: Develop a program to implement linear layout


and absolute layout.

 Practical Related Questions:

1. Name any 3 layout manager


Ans: The 3 layouts are:
i. Absolute Layout
ii. Linear Layout
iii. Relative Layout

2. What is card view?


Ans: Card View organizes content into a grid of cards. Card View is useful for
displaying a small to moderate amount of content.

 Exercise

1. Write a program to place Name, Age and mobile number linearly


(Vertical) on the display screen using Linear layout.

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


<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/and
roid"
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:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Name"

app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content">

</EditText>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Age"

app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content">

</EditText>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Mobile No."

app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content">

</EditText>

</LinearLayout>
2. Write a program to place Name, Age and mobile number centrally
on the display screen 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"
tools:context=".MainActivity">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Name"
android:layout_x="200px"
android:layout_y="561px" />

<EditText
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_x="200px"
android:layout_y="600px" >

</EditText>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Age"
android:layout_x="200px"
android:layout_y="761px"/>

<EditText
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_x="200px"
android:layout_y="800px">

</EditText>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Mobile No."
android:layout_x="200px"
android:layout_y="961px" />

<EditText
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_x="200px"
android:layout_y="1000px">

</EditText>
</AbsoluteLayout>

You might also like