0% found this document useful (0 votes)
14 views6 pages

Practical 6mad

The document contains XML layouts for three different Android UI components: FrameLayout, TableLayout, and RelativeLayout. Each layout specifies various UI elements such as ImageView, TextView, and Button with their respective attributes. The layouts are designed to be used in an Android application, showcasing different ways to arrange UI components 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 DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views6 pages

Practical 6mad

The document contains XML layouts for three different Android UI components: FrameLayout, TableLayout, and RelativeLayout. Each layout specifies various UI elements such as ImageView, TextView, and Button with their respective attributes. The layouts are designed to be used in an Android application, showcasing different ways to arrange UI components 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 DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

// Program to implement FrameLayout

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


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

<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@sample/img" />
</FrameLayout>

Output:
// Program to implement TableLayout

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

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Row1 Col1"
android:textAlignment="center"
android:textSize="20dp">

</TextView>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Row1 Col2"
android:textAlignment="center"
android:textSize="20dp">

</TextView>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Row1 Col3"
android:textAlignment="center"
android:textSize="20dp">

</TextView>
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Row2 Col1"
android:textAlignment="center"
android:textSize="20dp">
</TextView>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Row2 Col2"
android:textAlignment="center"
android:textSize="20dp">
</TextView>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Row2 Col3"
android:textAlignment="center"
android:textSize="20dp">
</TextView>

</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Row3 Col1"
android:textAlignment="center"
android:textSize="20dp">
</TextView>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Row3 Col2"
android:textAlignment="center"
android:textSize="20dp">

</TextView>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Row3 Col3"
android:textAlignment="center"
android:textSize="20dp">

</TextView>
</TableRow>
</TableLayout>

Output:

// Program to implement RelativeLayout


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#168BC34A"
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:layout_marginTop="35sp"
android:text="Top Left Button"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"/>

<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="35sp"
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"/>

<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bottom Right Button"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"/>

<Button 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>
Output:

You might also like