Ad Code

Responsive Advertisement

Basic Android Program 06

Question 06: Write a program to display all the data types in object-oriented programming using Frame layout.

Download hole Program / Project code, by clicking following link:

What is Grid Layout in Android Studio?
GridLayout is a layout manager in Android Studio that arranges views in a grid of rows and columns. It allows developers to create complex grid-based layouts, where each view is positioned in a cell defined by its row and column indices. GridLayout is a flexible layout manager that can be used to create a wide variety of user interfaces, including tables, calendars, and image galleries.
Some key features of GridLayout include:
  • Dynamic sizing: GridLayout can dynamically adjust the size of its cells based on the content of the views they contain, which allows it to adapt to different screen sizes and orientations.

  • Spanning: GridLayout supports views that span multiple rows or columns, which allows for more complex grid-based layouts.

  • Automatic alignment: GridLayout automatically aligns views in the same row or column, which simplifies the process of creating visually appealing user interfaces.

  • XML attributes: GridLayout can be customized using a variety of XML attributes, such as layout_row, layout_column, and layout_gravity.
Overall, GridLayout is a powerful layout manager in Android Studio that allows developers to create complex grid-based layouts with ease. It is particularly useful for creating user interfaces that are optimized for tablets and other large-screen devices, where grid-based layouts can help to maximize screen real estate and improve the user experience.


Programming Code:

Following code write in: MainActivity.java
package com.go2collage.practical_06;

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);
}
}

Following code write in: activity_main.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:layout_margin="20dp"
tools:context=".MainActivity">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="go2collage"
android:textSize="24sp"
android:textStyle="bold"
android:textAlignment="center"
android:layout_margin="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="HardcodedText" />

<ImageView
android:layout_width="225dp"
android:layout_height="202dp"
android:layout_gravity="center"
android:scaleType="fitCenter"
android:src="@drawable/ic_android_black_logo_24dp"
tools:ignore="ContentDescription" />

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Frame Layout"
android:textSize="18sp"
android:textColor="@color/black"
android:gravity="center"
android:layout_marginTop="220dp"
android:textAlignment="center"
android:textStyle="bold"
tools:ignore="HardcodedText" />

<ImageView
android:layout_width="337dp"
android:layout_height="424dp"
android:layout_gravity="center"
android:scaleType="fitCenter"
android:src="@drawable/ic_tablet_android_24"
tools:ignore="ContentDescription" />

</FrameLayout>

Output:



Post a Comment

0 Comments

Ad Code

Responsive Advertisement