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

Practical No 6

The document outlines a practical assignment for Mobile Application Development, focusing on implementing various layout types in Android, including FrameLayout, TableLayout, and RelativeLayout. It provides a list of layout attributes and explains the GridLayout, including its usage and differences from GridView. Additionally, it includes sample code for displaying student information in a table format and data types in object-oriented programming using FrameLayout.

Uploaded by

pirofa8256
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)
16 views16 pages

Practical No 6

The document outlines a practical assignment for Mobile Application Development, focusing on implementing various layout types in Android, including FrameLayout, TableLayout, and RelativeLayout. It provides a list of layout attributes and explains the GridLayout, including its usage and differences from GridView. Additionally, it includes sample code for displaying student information in a table format and data types in object-oriented programming using FrameLayout.

Uploaded by

pirofa8256
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/ 16

Mobile Application Development (22617) Ms. Batule P.

Practical No.6

Develop a program to implement frame layout, table layout and relative


layout.

Q.1) List different attributes which can be used with any layout managers.

ANS—

Attributes of Layout in Android


android:id: It uniquely identifies the Android Layout.
android:hint: It shows the hint of what to fill inside the EditText.
android:layout_height: It sets the height of the layout.
android:layout_width: It sets the width of the layout.

Q.2) What is Grid Layout?

ANS—
A grid layout in Android is a layout widget that arranges views in a grid using
rows and columns:
 How it works
GridLayout uses a grid of thin lines to divide the drawing area into cells, rows,
and columns. It supports column and row spanning, which allows a widget to
occupy a rectangular range of cells.
 How to use it
GridLayout uses the same XML API conventions as LinearLayout, so it should
be easy to use if you've already used LinearLayout.
 Difference from GridView
Although both GridView and GridLayout can arrange views in a grid, they are
different. GridView is a ViewGroup that groups views in a two-dimensional
scrolling grid.

Q.3) Write a program to display 10 students basic information in a table form


using Table layout.
Mobile Application Development (22617) Ms. Batule P.S

ANS—

MainActivity.java:
package com.blogspot.codingatharva.firstapp;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

}
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>

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

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:collapseColumns="*"

android:shrinkColumns="*"

tools:context=".MainActivity">

<TableRow

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:gravity="center_horizontal">

<TextView
Mobile Application Development (22617) Ms. Batule P.S

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="10 Students Basic Information"

android:textColor="#86AD33"

android:textSize="20dp"

android:textStyle="bold" />

</TableRow>

<TableRow

android:layout_width="match_parent"

android:layout_height="wrap_content">

<TextView

android:layout_width="0dp"

android:layout_weight="1"

android:text="Student Numbers"

android:textColor="#000"

android:textStyle="bold" />

<TextView

android:layout_width="0dp"

android:layout_weight="1"

android:text="Name"

android:textColor="#000"

android:textStyle="bold" />

<TextView

android:layout_width="0dp"

android:layout_weight="1"

android:text="RollNo"
Mobile Application Development (22617) Ms. Batule P.S

android:textColor="#000"

android:textStyle="bold" />

<TextView

android:layout_width="0dp"

android:layout_weight="1"

android:text="Age"

android:textColor="#000"

android:textStyle="bold" />

</TableRow>

<TableRow

android:layout_width="match_parent"

android:layout_height="wrap_content">

<TextView

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content"

android:text="Student 1:"

android:textColor="#86AD33"

android:textStyle="bold" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content"

/>

<EditText

android:layout_width="0dp"
Mobile Application Development (22617) Ms. Batule P.S

android:layout_weight="1"

android:layout_height="wrap_content" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

</TableRow>

<TableRow

android:layout_width="match_parent"

android:layout_height="wrap_content">

<TextView

android:layout_width="0dp"

android:layout_weight="1"

android:text="Student 2:"

android:textColor="#86AD33"

android:textStyle="bold" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

<EditText
Mobile Application Development (22617) Ms. Batule P.S

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

</TableRow>

<TableRow

android:layout_width="match_parent"

android:layout_height="wrap_content">

<TextView

android:layout_width="0dp"

android:layout_weight="1"

android:text="Student 3:"

android:textColor="#86AD33"

android:textStyle="bold" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

</TableRow>
Mobile Application Development (22617) Ms. Batule P.S

<TableRow

android:layout_width="match_parent"

android:layout_height="wrap_content">

<TextView

android:layout_width="0dp"

android:layout_weight="1"

android:text="Student 4:"

android:textColor="#86AD33"

android:textStyle="bold" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

</TableRow>

<TableRow

android:layout_width="match_parent"

android:layout_height="wrap_content">
Mobile Application Development (22617) Ms. Batule P.S

<TextView

android:layout_width="0dp"

android:layout_weight="1"

android:text="Student 5:"

android:textColor="#86AD33"

android:textStyle="bold" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

</TableRow>

<TableRow

android:layout_width="match_parent"

android:layout_height="wrap_content">

<TextView

android:layout_width="0dp"

android:layout_weight="1"
Mobile Application Development (22617) Ms. Batule P.S

android:text="Student 6:"

android:textColor="#86AD33"

android:textStyle="bold" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

</TableRow>

<TableRow

android:layout_width="match_parent"

android:layout_height="wrap_content">

<TextView

android:layout_width="0dp"

android:layout_weight="1"

android:text="Student 7:"

android:textColor="#86AD33"

android:textStyle="bold" />
Mobile Application Development (22617) Ms. Batule P.S

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

</TableRow>

<TableRow

android:layout_width="match_parent"

android:layout_height="wrap_content">

<TextView

android:layout_width="0dp"

android:layout_weight="1"

android:text="Student 8:"

android:textColor="#86AD33"

android:textStyle="bold" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />
Mobile Application Development (22617) Ms. Batule P.S

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

</TableRow>

<TableRow

android:layout_width="match_parent"

android:layout_height="wrap_content">

<TextView

android:layout_width="0dp"

android:layout_weight="1"

android:text="Student 9:"

android:textColor="#86AD33"

android:textStyle="bold" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"
Mobile Application Development (22617) Ms. Batule P.S

android:layout_height="wrap_content" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

</TableRow>

<TableRow

android:layout_width="match_parent"

android:layout_height="wrap_content">

<TextView

android:layout_width="0dp"

android:layout_weight="1"

android:text="Student 10:"

android:textColor="#86AD33"

android:textStyle="bold" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

<EditText

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content" />

<EditText

android:layout_width="0dp"
Mobile Application Development (22617) Ms. Batule P.S

android:layout_weight="1"

android:layout_height="wrap_content" />

</TableRow>

</TableLayout>

Q.4) Write a program to display all the data types in object-oriented


programming using Frame layout.

ANS—

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

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

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="wrap_content"

android:layout_height="match_parent"

tools:context=".MainActivity">

<TextView

android:layout_width="match_parent"

android:layout_height="66dp"

android:text="Data Types in Object Oriented Programming"

android:textSize="25dp"

android:textStyle="bold" />

<TextView

android:id="@+id/pd"

android:layout_width="wrap_content"

android:layout_height="wrap_content"
Mobile Application Development (22617) Ms. Batule P.S

android:layout_gravity="top|left|fill_vertical"

android:layout_marginTop="80dp"

android:text="Primitive"

android:textSize="20dp" />

<LinearLayout

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginLeft="20dp"

android:layout_marginTop="110dp"

android:foregroundGravity="fill_horizontal|top"

android:orientation="vertical">

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="1) Integer" />

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="2) Float" />

<TextView

android:layout_width="wrap_content"
Mobile Application Development (22617) Ms. Batule P.S

android:layout_height="wrap_content"

android:text="3) Characters" />

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="4) Boolean" />

</LinearLayout>

<TextView

android:layout_toRightOf="@+id/pd"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="right|fill_vertical"

android:layout_marginTop="80dp"

android:text="Non-Primitive"

android:textSize="20dp" />

<LinearLayout

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="right"

android:layout_marginTop="110dp"

android:layout_marginRight="20dp"

android:orientation="vertical">
Mobile Application Development (22617) Ms. Batule P.S

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="1) Class" />

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="2) Array" />

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="3) Interface" />

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="4) Object" />

</LinearLayout>
</FrameLayout>

You might also like