PR 6
PR 6
: 2215770083
Batch: T1 Roll No.: 12
Practical No. 6: Develop a program to implement frame layout, table layout and relative
layout.
X. Exercise
1. Write a program to display 10 students’ basic information in a table form using Table
layout.
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"
android:gravity="top|center"
android:outlineAmbientShadowColor="@color/black">
<TableRow> <TextView
android:text="Sr. no"
android:layout_weight="1"
android:textStyle="bold"/>
<TextView
android:text="Name of Student"
android:layout_weight="1"
android:textStyle="bold"/>
<TextView
android:text="Age"
android:layout_weight="1"
android:textStyle="bold"/>
</TableRow>
<TableRow> <TextView
android:text="1"
android:layout_weight="1"/>
<TextView
android:text="Tushar Neje"
android:layout_weight="1"/>
<TextView
android:text="18"
android:layout_weight="1"/>
</TableRow>
<TableRow> <TextView
android:text="2"
android:layout_weight="1"/>
<TextView
android:text="Kiran Shiudkar"
android:layout_weight="1"/>
<TextView android:text="19"
android:layout_weight="1"/>
</TableRow>
<TableRow> <TextView
android:text="3"
android:layout_weight="1"/>
<TextView
android:text="Rushabh Zore"
android:layout_weight="1"/>
<TextView
android:text="18"
android:layout_weight="1"/>
</TableRow>
<TableRow> <TextView
android:text="4"
android:layout_weight="1"/>
<TextView
android:text="Omkar Mali"
android:layout_weight="1"/>
<TextView
android:text="18"
android:layout_weight="1"/>
</TableRow>
<TableRow> <TextView
android:text="5"
android:layout_weight="1"/>
<TextView
android:text="Sushant Khadake"
android:layout_weight="1"/>
<TextView android:text="18"
android:layout_weight="1"/>
</TableRow>
<TableRow>
<TextView
android:text="6"
android:layout_weight="1"/>
<TextView
android:text="Sandesh Pol"
android:layout_weight="1"/>
<TextView
android:text="18"
android:layout_weight="1"/>
</TableRow>
<TableRow> <TextView
android:text="7"
android:layout_weight="1"/>
<TextView android:text="Irfan
Naikwade"
android:layout_weight="1"/>
<TextView android:text="18"
android:layout_weight="1"/>
</TableRow>
<TableRow> <TextView
android:text="8"
android:layout_weight="1"/>
<TextView
android:text="Vinayak Mali"
android:layout_weight="1"/>
<TextView
android:text="18"
android:layout_weight="1"/>
</TableRow>
<TableRow> <TextView
android:text="9"
android:layout_weight="1"/>
<TextView
android:text="Ram Kumar"
android:layout_weight="1"/>
<TextView
android:text="18"
android:layout_weight="1"/>
</TableRow>
<TableRow> <TextView
android:text="10"
android:layout_weight="1"/>
<TextView
android:text="Raj Kambale"
android:layout_weight="1"/>
<TextView
android:text="18"
android:layout_weight="1"/>
</TableRow>
</TableLayout> Program
(activity_main.xml) –
package com.example.androidapplication_pat6;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}}
Output –
2. Write a program to display all the data types in object-oriented programming using
Frame layout.
Program (MainActivity.java) –
<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:gravity="top|center"
android:outlineAmbientShadowColor="@color/black">
<TextView
android:layout_width="203dp"
android:layout_height="200dp"
android:layout_gravity="top|start"
android:gravity="center" android:text="Integer"
android:textColor="#000"
android:textSize="20dp"/>
<TextView
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_gravity="top|end" android:gravity="center"
android:text="Floating-point" android:textColor="#000"
android:textSize="20dp"/>
<TextView
android:layout_width="203dp"
android:layout_height="200dp"
android:layout_gravity="center|start"
android:gravity="center"
android:text="Boolean"
android:textColor="#000"
android:textSize="20dp"/>
<TextView
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_gravity="center|end"
android:gravity="center"
android:text="Character"
android:textColor="#000"
android:textSize="20dp"/>
<TextView
android:layout_width="203dp"
android:layout_height="200dp"
android:layout_gravity="bottom|start"
android:gravity="center"
android:text="Array"
android:textColor="#000"
android:textSize="20dp"/>
<TextView
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_gravity="bottom|end"
android:gravity="center"
android:text="Class"
android:textColor="#000"
android:textSize="20dp"/>
</FrameLayout>
Program (activity_main.xml) –
Output –