[go: up one dir, main page]

0% found this document useful (0 votes)
13 views12 pages

Practical No

The document includes code snippets for Android applications, specifically focusing on the layout files (XML) and main activity classes (Java) for two practical exercises. Practical No. 5 displays a simple user interface with personal information, while Practical No. 6 presents a table layout displaying names, ages, and percentages. Additionally, it highlights the use of Edge-to-Edge support and window insets for proper padding in the user interface.

Uploaded by

mpari8998
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)
13 views12 pages

Practical No

The document includes code snippets for Android applications, specifically focusing on the layout files (XML) and main activity classes (Java) for two practical exercises. Practical No. 5 displays a simple user interface with personal information, while Practical No. 6 presents a table layout displaying names, ages, and percentages. Additionally, it highlights the use of Edge-to-Edge support and window insets for proper padding in the user interface.

Uploaded by

mpari8998
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/ 12

Practical no.

 Activity_main.xml
 ?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:layout_editor_absoluteX="98dp"
tools:layout_editor_absoluteY="75dp">

<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Name:-Pushkar Surendra Singh" />

<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Age:-19" />

<TextView
android:id="@+id/textView4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Contact No:-8850341696" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
 MainActivity.java
 package com.example.pr5;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_main);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main),
(v, insets) -> {
Insets systemBars =
insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top,
systemBars.right, systemBars.bottom);
return insets;
});
}
}
Practical no.6
 Activity_main.xml
 <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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">

<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:padding="10dp"/>

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Age "
android:padding="10dp"/>/>

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Percentage"
android:padding="10dp"/>/>
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pushkar"
android:padding="10dp"/>/>

<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="19"
android:padding="10dp"/>/>
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="90.10%"
android:padding="10dp"/>/>
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Shreyas"
android:padding="10dp"/>/>

<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="16"
android:padding="10dp"/>/>

<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="85.90%"
android:padding="10dp"/>/>
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
android:id="@+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mayank"
android:padding="10dp"/>/>

<TextView
android:id="@+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="18"
android:padding="10dp"/>/>

<TextView
android:id="@+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="80.01%"
android:padding="10dp"/>/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Krishna"
android:padding="10dp"/>/>

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="18"
android:padding="10dp"/>/>

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="86.20%"
android:padding="10dp"/>/>
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Udit"
android:padding="10dp"/>/>

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="19"
android:padding="10dp"/>/>

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="72.12%"
android:padding="10dp"/>/>
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Krrish"
android:padding="10dp"/>/>

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="19"
android:padding="10dp"/>/>

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="83.47%"
android:padding="10dp"/>/>
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Kuber"
android:padding="10dp"/>/>

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="18"
android:padding="10dp"/>
/>

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="85.40%"
android:padding="10dp"/>/>
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sakshi"
android:padding="10dp"/>/>

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="19"
android:padding="10dp"/>/>
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="83.70%"
android:padding="10dp"/>/>
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Harshita"
android:padding="10dp"/>/>

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="20"
android:padding="10dp"/>/>

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="87.30%"
android:padding="10dp"/>/>
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Suchita"
android:padding="10dp"/>/>

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="17"
android:padding="10dp"/>/>

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="81.35%"
android:padding="10dp"/>/>
</TableRow>
</TableLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

 MainActivity.xml

package com.example.pr6;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_main);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main),
(v, insets) -> {
Insets systemBars =
insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right,
systemBars.bottom);
return insets;
});
}
}
 Activity_main.xml
 <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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">

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="@drawable/background_pr6" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingHorizontal="20dp"
android:paddingVertical="15dp">

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:rotationX="2"
android:text="List of Data Types In Object
Oriented Programming "
android:textColor="@color/white"
android:textSize="36sp" />

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Int"
android:textColor="@color/white"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Float"
android:textColor="@color/white"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Double"
android:textColor="@color/white"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Char"
android:textColor="@color/white"/>

</LinearLayout>
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
 MainActivity.xml
 package com.example.object_oriented_programming;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_main);

ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.mai
n), (v, insets) -> {
Insets systemBars =
insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top,
systemBars.right, systemBars.bottom);
return insets;
});
}
}

You might also like