0% found this document useful (0 votes)
88 views2 pages

Practical No 4: C. Programs Related To Different Layouts: Frame Layout

The document describes creating a frame layout in Android that displays 3 images on top of each other. It provides the XML code for the MainActivity layout file, which defines a frame layout containing 3 image views of different sizes. It also includes the Java code for the MainActivity class, which sets the content view to the layout file.

Uploaded by

Natsu Dragneel
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)
88 views2 pages

Practical No 4: C. Programs Related To Different Layouts: Frame Layout

The document describes creating a frame layout in Android that displays 3 images on top of each other. It provides the XML code for the MainActivity layout file, which defines a frame layout containing 3 image views of different sizes. It also includes the Java code for the MainActivity class, which sets the content view to the layout file.

Uploaded by

Natsu Dragneel
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/ 2

Practical no 4

c. Programs related to different Layouts: Frame layout.


1. Add 3 images in drawable as we have done in resources.
2. Write the following code:
MainActivity.xml
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >

<ImageView
android:id="@+id/imageView3"
android:layout_width="match_parent"
android:layout_height="254dp"
app:srcCompat="@drawable/images" />

<ImageView
android:id="@+id/imageView4"
android:layout_width="426dp"
android:layout_height="match_parent"
app:srcCompat="@drawable/images2" />

<ImageView
android:id="@+id/imageView5"
android:layout_width="467dp"
android:layout_height="1219dp"
app:srcCompat="@drawable/images3" />
</FrameLayout>

MainActivity.java
package com.example.pract1;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Output:-

You might also like