0% found this document useful (0 votes)
25 views

Android File Real

Uploaded by

nitintiwari7261
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)
25 views

Android File Real

Uploaded by

nitintiwari7261
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/ 62

Government Polytechnic Kashipur

(U.S Nagar)

Semester :– 5th
Session (2024-25)
Branch :- Computer Science & Engineering
Subject :- Android Application Development

Submitted To :- Submitted by :-
Mr. Kumar Gaurav
HOD C.S.E.
Index

S. NO. Name of the Practical Page NO. Date Signature

Study of Installation and configuration of


01.
Android Development Framework.

Study of various Android Development


02.
Environment.

Design an Application Environment


03.
representing a simple Calculator.

Development an Application for working with


04.
Menus and screen Navigation.

Develop an Application demonstrating internal


05. storage to store private data on the device
memory.

Design a simple to-do list Application using


06.
SQLite

Develop an application for connecting to the


07.
internet and sending email.

Develop an application for working with


08.
graphics and animations.

Develop an application for working with


09.
location based service.

Develop an application for working with


10.
device camera.
Practical No.-01
Study of Installation and configuration of Android
Development Framework.

Step 1: Head over to Install Android Studio | Download Now


to get the Android Studio executable or zip file.

Step 2: Click on the Download Android Studio Button.

Click on the “I have read and agree with the above terms and conditions”
checkbox followed by the download button.
Step 3: After the downloading has finished, open the file from downloads
and run it. It will prompt the following dialog box. Click on next. In the next
prompt, it’ll ask for a path for installation. Choose a path and hit next.

Step 4: It will start the installation, and once it is completed, it will be like
the image shown below.
Click on next.

Step 6: This will start the Android Studio.


Meanwhile, it will be finding the available SDK components.

Step 7: After it has found the SDK components, it will redirect to the
Welcome dialog box.

Click on Next.
Step 8: Now it is time to download the SDK components.

Click on finish

The Android Studio has been successfully configured. Now it’s time to
launch and build apps. Click on the Finish button to launch it.

Step 9: Click on Start a new Android Studio project to build a new app.
Practical No.-02

Study of Various Android Development Environment


(IDE)

Various Android Development Environment: -

• Android Studio

• Eclipse

• Visual Studio and Xamarin

• AIDE

• Droid Script

Android Studio

Android Studio is the official integrated development environment for


Android developers, designed specifically for mobile development, and
supported by Google and JetBrains. It’s built on top of the powerful IntelliJ
IDEA core, and has been with us since 2013, practically becoming the de
facto standard for Android development.

This IDE covers all required use cases, alongside providing efficient
debugging, syntax checkup, easy-to-use integration with AVD emulators,
and SDK management. The Android Software Development Kit (SDK)
integrates seamlessly with Android Studio, offering a comprehensive set of
tools and features tailored specifically for Android development. Plus, it’s
completely free of charge for all use types!

In fact, the tool is so well-regarded, that some developers look no further


than Android Studio.

Features of Android Studio:

• Intelligent code editor, providing advanced code completion,


refactoring, and code analysis in runtime.

• Support for code templates

• Built-in Android emulator that supports software testing on many


devices, including phones, tablets, TVs, watches, and cars

• Integration with Git, GitHub, and Bitbucket

• Build system is based on Gradle


• Support for Kotlin, Java, NDK, and C++

• Functionality can be expanded with plugins – for example, JavaScript


support

• Integration with Firebase and Google Cloud Platform

• Visual editor for XML and Jetpack Compose layouts

• Advanced debugging tools for every app’s layer

• Vector Asset Studio for creating, editing, and managing vector


graphics and image assets

• Translations Editor that helps edit locale files

• APK analyzer

• Integration with Android Debug Bridge (ADB)

• UI for browsing

• Managing connected devices

• Lint static code analysis framework includes over 365 lint checks
across the entirety of your app

• Apply Changes lets developers push code and resource changes to


the running app without restarting it – and in some cases, without
even restarting the current activity

The recent stable release – “Chipmunk” – introduced the following


changes:

• Janky frames detection for devices running at least Android 12


• Support for deploying preview of Jetpack Compose UI from Library
Modules

• Long list of small fixes and added support for the newest Gradle and
Android SDK versions

Eclipse

Eclipse is a free and open-source IDE that was initially developed by IBM
and is currently maintained by the Eclipse Foundation. Before the rise of
Android Studio, Eclipse was widely used with ADT (Android Development
Tools) to provide an integrated development environment for Android app
development. It’s one of the most popular IDEs on the market thanks to its
support for over 100 programming languages, including C++, JavaScript,
Ada, and Rust. Eclipse is a full-featured, powerful IDE that enables
developers to write top-class software, which is why it’s on our best IDEs
for Android development list.

Features of Eclipse IDE:

• Version Control Software integration


• Build tools integration with Gradle, Maven, and Apache Ant

• Wide range of plugins for extending IDE functionality

• Code completion tool and syntax checker

Visual Studio and Xamarin

Xamarin is a free and open-source mobile application platform. It’s used for
building native and high-performance iOS, Android, tvOS, watchOS,
macOS, and Windows apps in C#. Meanwhile, Visual Studio is the most
popular tool for writing code using C#. Visual Studio and Xamarin
streamline the entire app development process by providing a
comprehensive set of tools and features to accelerate development,
simplify integration of native device features, and offer debugging support.

Xamarin enables developers to share an average of 90% of their


applications across platforms. This pattern allows developers to write their
business logic in a single language (or reuse existing application code),
while achieving native performance, look, and feel across each platform.
Features of Visual Studio with Xamarin:

• Interface builder, allowing developers to prototype an entire user


interface without writing any code

• Integration with Git

• Test-driven development environment

• Integration with Vim text editor

• Mobile cross-platform support

AIDE

AIDE allows the development of Android apps and websites directly


on mobile devices. It enables users to visually design apps and write code,
but also offers real-time error checking, refactoring, and smart code
navigation.

Features of AIDE:
• What You See Is What You Get (WYSIWYG) editor

• Possible to build apps directly on Android devices

• Projects are compatible with other IDEs

• Fast prototyping

Droid Script

Droid Script is an easy-to-use, portable coding tool that simplifies mobile


app development by allowing you to create mobile apps with JavaScript. It
is considered one of the best app development software options for
creating Android applications.

Main features of Droid Script:

• Free (although there is premium access)

• Possible to build apps directly on Android devices

• Integration with HTML


Practical No.-03
Design an Application Environment representing a
simple Calculator.
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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="wrap_content"
tools:context=".MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/solution_tv"
android:textSize="32dp"
android:textAlignment="textEnd"
android:textColor="@color/black"
android:layout_above="@id/result_tv"
android:layout_margin="16dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/result_tv"
android:text="0"
android:textSize="64dp"
android:textAlignment="textEnd"
android:textColor="@color/black"
android:layout_above="@id/buttons_layout"
android:layout_margin="16dp"
/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:background="#F1F1F1"
android:paddingVertical="16dp"
android:id="@+id/buttons_layout">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">

<com.google.android.material.button.MaterialButton
android:layout_width="72dp"
android:layout_height="72dp"
app:cornerRadius="360dp"

style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:textSize="32dp"
android:textColor="@color/white"
android:layout_margin="12dp"
android:id="@+id/button_c"
app:backgroundTint="#F44134"
android:text="C"/>
<com.google.android.material.button.MaterialButton
android:layout_width="72dp"
android:layout_height="72dp"
app:cornerRadius="360dp"

style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:textSize="32dp"
android:textColor="@color/white"
android:layout_margin="12dp"
android:id="@+id/button_open_bracket"
app:backgroundTint="#8E8E8D"
android:text="("/>
<com.google.android.material.button.MaterialButton
android:layout_width="72dp"
android:layout_height="72dp"
app:cornerRadius="360dp"

style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:textSize="32dp"
android:textColor="@color/white"
android:layout_margin="12dp"
android:id="@+id/button_close_bracket"
app:backgroundTint="#8E8E8D"
android:text=")"/>
<com.google.android.material.button.MaterialButton
android:layout_width="72dp"
android:layout_height="72dp"
app:cornerRadius="360dp"

style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:textSize="32dp"
android:textColor="@color/white"
android:layout_margin="12dp"
android:id="@+id/button_divide"
app:backgroundTint="#FF9800"
android:text="/"/>

</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">

<com.google.android.material.button.MaterialButton
android:layout_width="72dp"
android:layout_height="72dp"
app:cornerRadius="360dp"
style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:textSize="32dp"
android:textColor="@color/white"
android:layout_margin="12dp"
android:id="@+id/button_7"
android:text="7"/>
<com.google.android.material.button.MaterialButton
android:layout_width="72dp"
android:layout_height="72dp"
app:cornerRadius="360dp"

style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:textSize="32dp"
android:textColor="@color/white"
android:layout_margin="12dp"
android:id="@+id/button_8"
android:text="8"/>
<com.google.android.material.button.MaterialButton
android:layout_width="72dp"
android:layout_height="72dp"
app:cornerRadius="360dp"

style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:textSize="32dp"
android:textColor="@color/white"
android:layout_margin="12dp"
android:id="@+id/button_9"
android:text="9"/>
<com.google.android.material.button.MaterialButton
android:layout_width="72dp"
android:layout_height="72dp"
app:cornerRadius="360dp"

style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:textSize="32dp"
android:textColor="@color/white"
android:layout_margin="12dp"
android:id="@+id/button_multiply"
app:backgroundTint="#FF9800"
android:text="X"/>

</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">

<com.google.android.material.button.MaterialButton
android:layout_width="72dp"
android:layout_height="72dp"
app:cornerRadius="360dp"

style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:textSize="32dp"
android:textColor="@color/white"
android:layout_margin="12dp"
android:id="@+id/button_4"
android:text="4"/>
<com.google.android.material.button.MaterialButton
android:layout_width="72dp"
android:layout_height="72dp"
app:cornerRadius="360dp"

style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:textSize="32dp"
android:textColor="@color/white"
android:layout_margin="12dp"
android:id="@+id/button_5"
android:text="5"/>
<com.google.android.material.button.MaterialButton
android:layout_width="72dp"
android:layout_height="72dp"
app:cornerRadius="360dp"

style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:textSize="32dp"
android:textColor="@color/white"
android:layout_margin="12dp"
android:id="@+id/button_6"
android:text="6"/>
<com.google.android.material.button.MaterialButton
android:layout_width="72dp"
android:layout_height="72dp"
app:cornerRadius="360dp"

style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:textSize="32dp"
android:textColor="@color/white"
android:layout_margin="12dp"
android:id="@+id/button_plus"
app:backgroundTint="#FF9800"
android:text="+"/>

</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">

<com.google.android.material.button.MaterialButton
android:layout_width="72dp"
android:layout_height="72dp"
app:cornerRadius="360dp"

style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:textSize="32dp"
android:textColor="@color/white"
android:layout_margin="12dp"
android:id="@+id/button_1"
android:text="1"/>
<com.google.android.material.button.MaterialButton
android:layout_width="72dp"
android:layout_height="72dp"
app:cornerRadius="360dp"

style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:textSize="32dp"
android:textColor="@color/white"
android:layout_margin="12dp"
android:id="@+id/button_2"
android:text="2"/>
<com.google.android.material.button.MaterialButton
android:layout_width="72dp"
android:layout_height="72dp"
app:cornerRadius="360dp"

style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:textSize="32dp"
android:textColor="@color/white"
android:layout_margin="12dp"
android:id="@+id/button_3"
android:text="3"/>
<com.google.android.material.button.MaterialButton
android:layout_width="72dp"
android:layout_height="72dp"
app:cornerRadius="360dp"

style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:textSize="32dp"
android:textColor="@color/white"
android:layout_margin="12dp"
android:id="@+id/button_minus"
app:backgroundTint="#FF9800"
android:text="-"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">

<com.google.android.material.button.MaterialButton
android:layout_width="72dp"
android:layout_height="72dp"
app:cornerRadius="360dp"

style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:textSize="20dp"
android:textColor="@color/white"
android:layout_margin="12dp"
android:id="@+id/button_ac"
app:backgroundTint="#F44336"
android:text="AC"/>
<com.google.android.material.button.MaterialButton
android:layout_width="72dp"
android:layout_height="72dp"
app:cornerRadius="360dp"

style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:textSize="32dp"
android:textColor="@color/white"
android:layout_margin="12dp"
android:id="@+id/button_0"
android:text="0"/>
<com.google.android.material.button.MaterialButton
android:layout_width="72dp"
android:layout_height="72dp"
app:cornerRadius="360dp"

style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:textSize="32dp"
android:textColor="@color/white"
android:layout_margin="12dp"
android:id="@+id/button_dot"
android:text="."/>
<com.google.android.material.button.MaterialButton
android:layout_width="72dp"
android:layout_height="72dp"
app:cornerRadius="360dp"

style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:textSize="32dp"
android:textColor="@color/white"
android:layout_margin="12dp"
android:id="@+id/button_equals"
app:backgroundTint="#FF9800"
android:text="="/>

</LinearLayout>
</LinearLayout>

</RelativeLayout>

MainActivity.java
package com.example.myapplication;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable;
import com.google.android.material.button.MaterialButton;

public class MainActivity extends AppCompatActivity implements


View.OnClickListener{

TextView resultTv,solutionTv;
MaterialButton buttonC,buttonBrackOpen,buttonBrackClose;
MaterialButton
buttonDivide,buttonMultiply,buttonPlus,buttonMinus,buttonEquals;
MaterialButton
button0,button1,button2,button3,button4,button5,button6,button7,button8,
button9;
MaterialButton buttonAC,buttonDot;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_main);
resultTv=findViewById(R.id.result_tv);
solutionTv=findViewById(R.id.solution_tv);

assignId(buttonC,R.id.button_c);
assignId(buttonBrackOpen,R.id.button_open_bracket);
assignId(buttonBrackClose,R.id.button_close_bracket);
assignId(buttonDivide,R.id.button_divide);
assignId(buttonMultiply,R.id.button_multiply);
assignId(buttonPlus,R.id.button_plus);
assignId(buttonMinus,R.id.button_minus);
assignId(buttonEquals,R.id.button_equals);
assignId(button0,R.id.button_0);
assignId(button1,R.id.button_1);
assignId(button2,R.id.button_2);
assignId(button3,R.id.button_3);
assignId(button4,R.id.button_4);
assignId(button5,R.id.button_5);
assignId(button6,R.id.button_6);
assignId(button7,R.id.button_7);
assignId(button8,R.id.button_8);
assignId(button9,R.id.button_9);
assignId(buttonAC,R.id.button_ac);
assignId(buttonDot,R.id.button_dot);
}

void assignId(MaterialButton btn, int id){


btn=findViewById(id);
btn.setOnClickListener(this);
}
@Override
public void onClick(View view) {
MaterialButton button=(MaterialButton) view;
String buttonText=button.getText().toString();
String dataToCalculate=solutionTv.getText().toString();

if(buttonText.equals("AC")){
solutionTv.setText("");
resultTv.setText("0");
return;
}
if(buttonText.equals("=")){
solutionTv.setText(resultTv.getText());
return;
}
if(buttonText.equals("C")){
dataToCalculate=dataToCalculate.substring(0,dataToCalculate.length()-
1);
}
else{
dataToCalculate=dataToCalculate+buttonText;
}

solutionTv.setText(dataToCalculate);
String finalResult=getResult(dataToCalculate);
if(!finalResult.equals("Err")){
resultTv.setText(finalResult);
}
}
String getResult(String data){
try{
Context context=Context.enter();
context.setOptimizationLevel(-1);
Scriptable scriptable=context.initStandardObjects();
String finalResult=
context.evaluateString(scriptable,data,"Javascript",1,null).toString();
if (finalResult.endsWith(".0")){
finalResult=finalResult.replace(".0","");
}
return finalResult;
}
catch (Exception e){
return "Err";
}

}
}
Output:-
Practical No.-04
Development an Application for working with Menus
and screen navigation.
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
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"
tools:openDrawer="start"
android:id="@+id/drawerLayout"
android:fitsSystemWindows="true"
tools:context=".MainActivity">

<include
layout="@layout/activity_main_content"/>

<com.google.android.material.navigation.NavigationView
android:id="@+id/navigationView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:menu="@menu/drawer_items"
app:itemIconPadding="30dp"
app:dividerInsetStart="60dp"
app:headerLayout="@layout/drawer_header"
android:layout_gravity="start"/>
</androidx.drawerlayout.widget.DrawerLayout>

activity_main_content.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#D5D4D4">

<ImageButton
android:id="@+id/buttonDrawerToggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/drawer_menu"
android:background="@android:color/transparent"
android:padding="10dp"/>

</androidx.appcompat.widget.Toolbar>

</LinearLayout>

drawer_header.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:padding="20dp"
android:background="#00BCD4"
android:gravity="bottom"
android:layout_height="180dp">

<androidx.cardview.widget.CardView
android:layout_width="60dp"
android:layout_height="60dp"
app:cardCornerRadius="40dp"
app:cardElevation="0dp"
android:backgroundTint="#C1BDBD">>

<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/person"/>
</androidx.cardview.widget.CardView>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="User Name"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:textColor="@color/black"
android:textStyle="bold"
android:textSize="15sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="User Email"
android:textColor="#646363"
android:textStyle="normal"
android:textSize="13sp"/>

</LinearLayout>

drawer_items.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

<group
android:id="@+id/group1">
<item
android:icon="@drawable/menu"
android:id="@+id/navMenu"
android:title="Menu"/>

<item
android:icon="@drawable/cart"
android:id="@+id/navCart"
android:title="Cart"/>

<item
android:icon="@drawable/favourite"
android:id="@+id/navFavourite"
android:title="Favourite"/>

</group>

<group
android:id="@+id/group2">
<item
android:icon="@drawable/ongoing"
android:id="@+id/navOrders"
android:title=" Ongoing Orders"/>

<item
android:icon="@drawable/history"
android:id="@+id/navHistory"
android:title="History"/>

</group>

<group
android:id="@+id/group3">
<item
android:icon="@drawable/feedback"
android:id="@+id/navFeedback"
android:title="Feedback"/>

<item
android:icon="@drawable/terms"
android:id="@+id/navTerms"
android:title="Terms and Conditions"/>

<item
android:icon="@drawable/contact"
android:id="@+id/navContact"
android:title="Contact us"/>

</group>

<group
android:id="@+id/group4">
<item
android:icon="@drawable/share"
android:id="@+id/navShare"
android:title="Share"/>

</group>

</menu>

Main_activity.java

package com.example.drawernavigation;

import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageButton;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.drawerlayout.widget.DrawerLayout;

import com.google.android.material.navigation.NavigationView;

public class MainActivity extends AppCompatActivity {

DrawerLayout drawerLayout;
ImageButton buttonDrawerToggle;
NavigationView navigationView;

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

drawerLayout=findViewById(R.id.drawerLayout);
buttonDrawerToggle=findViewById(R.id.buttonDrawerToggle);
navigationView=findViewById(R.id.navigationView);

buttonDrawerToggle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
drawerLayout.open();
}
});
navigationView.setNavigationItemSelectedListener(new
NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
int itemiId= item.getItemId();
if(itemiId==R.id.navMenu){
Toast.makeText(MainActivity.this,"Menu
Clicked",Toast.LENGTH_SHORT).show();
}
if(itemiId==R.id.navCart){
Toast.makeText(MainActivity.this,"Cart
Clicked",Toast.LENGTH_SHORT).show();
}
if(itemiId==R.id.navOrders){
Toast.makeText(MainActivity.this,"Ongoing Order
Clicked",Toast.LENGTH_SHORT).show();
}
if(itemiId==R.id.navHistory){
Toast.makeText(MainActivity.this,"History
Clicked",Toast.LENGTH_SHORT).show();
}
if(itemiId==R.id.navFavourite){
Toast.makeText(MainActivity.this,"Favourite
Clicked",Toast.LENGTH_SHORT).show();
}
if(itemiId==R.id.navContact){
Toast.makeText(MainActivity.this,"Contact
Clicked",Toast.LENGTH_SHORT).show();
}
if(itemiId==R.id.navFeedback){
Toast.makeText(MainActivity.this,"Feedback
Clicked",Toast.LENGTH_SHORT).show();
}
if(itemiId==R.id.navTerms){
Toast.makeText(MainActivity.this,"Terms and Conditions
Clicked",Toast.LENGTH_SHORT).show();
}
if(itemiId==R.id.navShare){
Toast.makeText(MainActivity.this,"Share
Clicked",Toast.LENGTH_SHORT).show();
}
drawerLayout.close();

return false;
}
});

}
}
Output:-
Practical:5
Develop an application demonstrating internal storage to
store private data on the device memory.

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">

<TextView

android:id="@+id/textView2"
android:layout_width="337dp"
android:layout_height="28dp" android:text="
File Content "
android:textAlignment="center"
android:textColor="#000"
android:textSize="24sp"
android:textStyle="bold"

app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.52" />

<Button

android:id="@+id/write_button"
android:layout_width="wrap_content"
android:layout_height="48dp" android:layout_marginStart="160dp"
android:layout_marginEnd="159dp"
android:layout_marginBottom="16dp"

android:text="Write"

app:layout_constraintBottom_toTopOf="@+id/read_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.904" />

<Button

android:id="@+id/read_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="160dp"
android:layout_marginEnd="158dp"
android:layout_marginBottom="48dp"

android:text="Read"

app:layout_constraintBottom_toTopOf="@+id/textView2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"

app:layout_constraintStart_toStartOf="parent" />

<EditText

android:id="@+id/userInput"
android:layout_width="319dp"
android:layout_height="50dp"
android:layout_marginStart="46dp"
android:layout_marginTop="91dp"
android:layout_marginEnd="46dp"

android:ems="10"
android:inputType="textPersonName"

android:text="Name"

app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/content"
android:layout_width="332dp"
android:layout_height="306dp"
android:layout_marginStart="33dp"
android:layout_marginTop="21dp"
android:layout_marginEnd="33dp"
android:layout_marginBottom="6dp"
android:text=""
android:textAlignment="center"
android:textColor="#000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.461"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2"
app:layout_constraintVertical_bias="0.0" />

</androidx.constraintlayout.widget.ConstraintLayout>

MainActivity.java
package com.example.internalstorage;

import android.content.Context;
import android.os.Bundle; import
android.view.View; import
android.widget.Button; import
android.widget.EditText;

import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import androidx.core.graphics.Insets; import


androidx.core.view.ViewCompat; import
androidx.core.view.WindowInsetsCompat;

import java.io.FileInputStream; import


java.io.FileOutputStream;

import java.io.IOException;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

// declare the variables

Button read, write;

EditText userInput;

TextView fileContent;

String filename = "myfile.txt"; // Define your filename here

@Override

protected void onCreate(Bundle savedInstanceState) {


super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// Handle system bars (optional)

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;

});

// Initialize the UI components read


= findViewById(R.id.read_button); write =
findViewById(R.id.write_button);
userInput = findViewById(R.id.userInput);

fileContent = findViewById(R.id.content);

// Set click listeners


read.setOnClickListener(this);
write.setOnClickListener(this); }

@Override

public void onClick(View view) {

Button b = (Button) view;

// Get the button text: either 'read' or 'write' depending on the button
pressed

String b_text = b.getText().toString();

switch (b_text.toLowerCase()) {

case "write": {
writeData(); break;

case "read": {
readData(); break;

}
private void writeData() {

try {

// Write the input text to the file

FileOutputStream fos = openFileOutput(filename, Context.MODE_PRIVATE);


String data = userInput.getText().toString(); fos.write(data.getBytes());

fos.flush();

fos.close();

} catch (IOException e) {
e.printStackTrace();

userInput.setText(""); // Clear the input field

printMessage("Writing to file " + filename + " completed...");

private void readData() {

try {

// Read the content of the file

FileInputStream fin = openFileInput(filename);


int a;

StringBuilder temp = new StringBuilder();

while ((a = fin.read()) != -1) {

temp.append((char) a);

// Set the file content to the TextView

fileContent.setText(temp.toString());
fin.close();

} catch (IOException e) {
e.printStackTrace();

printMessage("Reading from file " + filename + " completed...");

}
// A simple method to print messages to the fileContent TextView
private void printMessage(String message) {

fileContent.append("\n" + message);

}}

OUTPUT
Practical: 6
Design a simple to-do list application using SQLite

MainActivity.java

package com.example.to Do. List; import


android.app.Activity; import
android.database.Cursor; import
android.os.Bundle; import
android.view.Menu; import
android.view.MenuItem; import
android.view.View; import
android.widget.EditText; import
android.widget.ListAdapter; import
android.widget.ListView; import
android.widget.SimpleCursorAdapter; public
class MainActivity extends Activity {
EditText text1,text2;
DatabaseHelper dbHelp;
ListView alist; @Override protected void
onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); text1 =
(EditText) findViewById(R.id.EText1); text2 =
(EditText) findViewById(R.id.EText2); dbHelp = new
DatabaseHelper(this); alist = (ListView)
findViewById(R.id.newlist);
// alist = getListView();
getData();
}
@Override public boolean
onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override public boolean
onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void addNew(View view) {
String s1 = text1.getText().toString();
String s2 = text2.getText().toString();
dbHelp.addData(s1,s2);
getData();
}
public void getData()
{
Cursor cursor = dbHelp.fetchData();
ListAdapter myAdapter = new SimpleCursorAdapter(this,R.layout.tasks,
cursor,
new String[]{dbHelp._ID,dbHelp.COLUMN_1,dbHelp.COLUMN_2},
new int[]{R.id.idnum,R.id.c1,R.id.c2},0);
alist.setAdapter(myAdapter); }
}

activity_main.xml

<RelativeLayout 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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<TextView android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/AppName"
android:layout_centerHorizontal="true"
android:textColor="#ff18be1c" android:textSize="20dp/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/input1"
android:layout_below="@+id/AppName"
android:id="@+id/EText1"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/input2"
android:layout_below="@+id/EText1"
android:id="@+id/EText2"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/EText2"
android:text="@string/submit"
android:onClick="addNew"
android:id="@+id/button"
android:layout_centerHorizontal="true"
android:textColor="#ff725fee"
/>
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/newlist"
android:layout_below="@+id/button">
</ListView>

DataBaseHelper.java
package com.example.to Do.List; import

android.content.ContentValues; import

android.content.Context; import android.database.Cursor;

import android.database.sqlite.SQLiteDatabase; import

android.database.sqlite.SQLiteOpenHelper; public class

DatabaseHelper extends SQLiteOpenHelper { public

static final String DATABASE_NAME="DbApp"; public

static final int DATABASE_VERSION=1; public static final

String TABLE = "DbTable"; public static final String _ID =

"id"; public static final String COLUMN_1="Task";

public static final String COLUMN_2="status"; public

static final String CREATE_TABLE="CREATE TABLE "


+ TABLE + " ( "

+ _ID + " INTEGER PRIMARY KEY, "

+ COLUMN_1 + " TEXT, " + COLUMN_2 + " TEXT)";

public DatabaseHelper(Context context) { super(context,

DATABASE_NAME, null, DATABASE_VERSION);

public void addData(String s1,String s2)

SQLiteDatabase db = this.getWritableDatabase();

ContentValues values = new ContentValues();

values.put(COLUMN_1,s1); values.put(COLUMN_2,s2);

db.insert(TABLE,null,values);

db.close();

public Cursor fetchData()

SQLiteDatabase db = this.getReadableDatabase();

String str = ("SELECT rowid _id, * FROM DbTable");

return db.rawQuery(str,null);

@Override public void

onCreate(SQLiteDatabase db) {

db.execSQL(CREATE_TABLE);

@Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int

newVersion) { db.execSQL("DROP TABLE IF EXISTS " + TABLE);

onCreate(db);

}
Tasks.xml

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


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/idnum"
android:paddingRight="20dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/c1"
android:layout_toRightOf="@+id/idnum"
android:paddingRight="20dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/c2"
android:layout_toRightOf="@+id/c1"/>

OUTPUT
Practical:7
Develop an application for connecting to the internet and
sending email.
MainActivity.java

package com.example.sendingEmail;
import android.net.Uri; import
android.os.Bundle; import
android.app.Activity; import
android.content.Intent; import
android.util.Log; import
android.view.Menu; import
android.view.View; import
android.widget.Button; import
android.widget.Toast; public class
MainActivity extends Activity {

@Override protected void onCreate(Bundle


savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button startBtn = (Button) findViewById(R.id.sendEmail);
startBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
sendEmail();
}
});
}
protected void sendEmail() {
Log.i("Send email", "");
String[] TO = {""};
String[] CC = {""};
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto:"));
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
emailIntent.putExtra(Intent.EXTRA_CC, CC);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Your subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Email message goes here")
try {
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
finish();
Log.i("Finished sending email...", "");
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MainActivity.this, "There is no email client installed.",
Toast.LENGTH_SHORT).show();
}
}
}

Activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent" android:layout_height="fill_parent"

android:orientation="vertical" >

<TextView

android:id="@+id/textView1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Sending Mail Example"

android:layout_alignParentTop="true"

android:layout_centerHorizontal="true"

android:textSize="30dp" />
<TextView android:id="@+id/textView2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Tutorials point "

android:textColor="#ff87ff09"

android:textSize="30dp"

android:layout_above="@+id/imageButton"

android:layout_alignRight="@+id/imageButton"

android:layout_alignEnd="@+id/imageButton" />

<ImageButton

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:id="@+id/imageButton"

android:src="@drawable/abc"

android:layout_centerVertical="true"

android:layout_centerHorizontal="true" />

<Button android:id="@+id/sendEmail"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="@string/compose_email"/>

</LinearLayout>
OUTPUT
Practical-8
Develop an application for working with graphics and
animations

(Animation)

activity_main.xml
<RelativeLayout

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

android:layout_width="match_parent"

android:layout_height="match_parent">

<ImageView android:id="@+id/imageView"

android:layout_width="100dp"

android:layout_height="100dp"

android:src="@drawable/ic_launcher_foreground"

android:layout_centerInParent="true" />

<Button

android:id="@+id/animateButton"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Animate"

android:layout_alignParentBottom="true"

android:layout_centerHorizontal="true"

android:layout_marginBottom="30dp" />

</RelativeLayout>

MainActivity.java
package com.example.animationapp; import

android.animation.ObjectAnimator; import

android.os.Bundle;

import android.view.View; import

android.widget.Button; import
android.widget.ImageView; import

androidx.appcompat.app.AppCompatActivity; public

class MainActivity extends AppCompatActivity {

@Override protected void onCreate(Bundle

savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

ImageView imageView = findViewById(R.id.imageView);

Button animateButton = findViewById(R.id.animateButton);

animateButton.setOnClickListener(new View.OnClickListener() {

@Override public

void onClick(View v) {

// Move the ImageView from its current position to a new one

ObjectAnimator animator = ObjectAnimator.ofFloat(imageView, "translationY", 0f, 500f);

animator.setDuration(1000); // 1 second

animator.start();

});

OUTPUT--
(Graphics)

MainActivity.java
package com.example.simplegraphics;
import android.os.Bundle; import
android.app.Activity; import
android.view.Menu; import
android.content.Context; import
android.graphics.Canvas; import
android.graphics.Color; import
android.graphics.Paint; import
android.view.View; public class
MainActivity extends Activity {
DemoView demoview;
@Override public void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
demoview = new DemoView(this);
setContentView(demoview);
}
private class DemoView extends View{
public DemoView(Context context){
super(context);
}
@Override protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.WHITE);
canvas.drawPaint(paint); paint.setAntiAlias(false);
paint.setColor(Color.BLUE);
canvas.drawCircle(20, 20, 15, paint);
paint.setAntiAlias(true);
paint.setColor(Color.GREEN);
canvas.drawCircle(60, 20, 15, paint);
paint.setAntiAlias(false);
paint.setColor(Color.RED); canvas.drawRect(100, 5,
200, 30, paint);

canvas.rotate(-45);
paint.setStyle(Paint.Style.FILL);
canvas.drawText("Graphics Rotation", 40, 180, paint);
canvas.restore();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}

activity_main.xml
<RelativeLayout xmlns: androidclass="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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</RelativeLayout>

OUTPUT
Pratctical-9
Develop an application for working with location based
service

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

<LinearLayout

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

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

android:layout_width="match_parent"

android:orientation="vertical" android:layout_gravity="center"

android:gravity="center"

android:layout_height="match_parent"

tools:context=".MainActivity">

<ImageView

android:src="@drawable/location"

android:layout_width="200dp"

android:layout_height="200dp"/>

<TextView

android:id="@+id/text_location"

android:textSize="18sp"

android:textStyle="bold"

android:layout_margin="10dp"

android:text="Current Location"

android:layout_width="match_parent"

android:layout_height="wrap_content"/>

<Button

android:id="@+id/button_location"

android:text="Get Location"
android:layout_width="wrap_content"

android:layout_height="wrap_content"/>

</LinearLayout>

MainActivity.java
package com.example.mycurrentlocation; import

androidx.appcompat.app.AppCompatActivity; import

androidx.core.app.ActivityCompat; import

androidx.core.content.ContextCompat; import

android.Manifest; import

android.annotation.SuppressLint; import

android.content.pm.PackageManager; import

android.location.Address; import

android.location.Geocoder; import

android.location.Location; import

android.location.LocationListener; import

android.location.LocationManager; import

android.os.Bundle; import android.view.View; import

android.widget.Button; import

android.widget.TextView; import

android.widget.Toast;

import java.util.List; import java.util.Locale; public class MainActivity extends

AppCompatActivity implements LocationListener {

Button button_location;

TextView textView_location;

LocationManager locationManager;

@Override protected void onCreate(Bundle

savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);
textView_location = findViewById(R.id.text_location);

button_location = findViewById(R.id.button_location);

//Runtime permissions

if (ContextCompat.checkSelfPermission(MainActivity.this,
Manifest.permission.ACCESS_FINE_LOCATION)

!= PackageManager.PERMISSION_GRANTED){

ActivityCompat.requestPermissions(MainActivity.this,new String[]{

Manifest.permission.ACCESS_FINE_LOCATION

},100);

button_location.setOnClickListener(new View.OnClickListener() {

@Override public

void onClick(View v) {

//create method

getLocation();

});

@SuppressLint("MissingPermission")

private void getLocation() {

try {

locationManager = (LocationManager)

getApplicationContext().getSystemService(LOCATION_SERVICE);

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,5000,5,MainActivity.thi
s

);

}catch (Exception e){

e.printStackTrace();

}
@Override public void

onLocationChanged(Location location) {

Toast.makeText(this, ""+location.getLatitude()+","+location.getLongitude(),
Toast.LENGTH_SHORT).show();

try {

Geocoder geocoder = new Geocoder(MainActivity.this, Locale.getDefault());

List<Address> addresses =

geocoder.getFromLocation(location.getLatitude(),location.getLongitude(),1);

String address = addresses.get(0).getAddressLine(0);

textView_location.setText(address);

}catch (Exception e){

e.printStackTrace();

@Override public void onStatusChanged(String provider, int status,

Bundle extras) {

@Override public void

onProviderEnabled(String provider) {

@Override public void

onProviderDisabled(String provider) {

}
OUTPUT
Practical 10
Develop an application for working with device camera.
MainActivity.java
package com.example.cameraapp; import
android.app.Activity; import
android.content.Intent; import
android.os.Bundle; import
android.provider.MediaStore; import
android.view.Menu; import
android.view.View; import
android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity {
Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn=(Button)findViewById(R.id.button1);
btn.setOnClickListener(new OnClickListener() {

public void onClick(View v) {


// TODO Auto-generated method stub
Intent i=new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
startActivity(i);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu); return true;
}
}

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"> <RelativeLayout

android:layout_width="match_parent"
android:layout_height="wrap_content" android:orientation="vertical">

<Button

android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="81dp"
android:layout_marginTop="54dp"
android:text="Button" />

</RelativeLayout>

</android>

OUTPUT

You might also like