Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Java Arrays
  • Java Strings
  • Java OOPs
  • Java Collection
  • Java 8 Tutorial
  • Java Multithreading
  • Java Exception Handling
  • Java Programs
  • Java Project
  • Java Collections Interview
  • Java Interview Questions
  • Java MCQs
  • Spring
  • Spring MVC
  • Spring Boot
  • Hibernate
Open In App
Next Article:
How to Build a Simple Notes App in Android?
Next article icon

How to Build a Simple Bill Splitter App in Android?

Last Updated : 26 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Many payment applications such as Paytm, PhonePe, and others provide the functionality to split the bills among a number of people to divide it equally. This is a very useful feature that helps users to split the bills amongst each other. In this article, we will take a look at How to create a simple Bill Splitter app in Android. A sample video is given below to get an idea about what we are going to do in this article.

https://media.geeksforgeeks.org/wp-content/uploads/20221005132847/Screenrecorder-2022-10-05-13-23-33-669.mp4

Note: This Android article covered in both Java and Kotlin languages. 

Step by Step Implementation

Step 1: Create a New Project in Android Studio

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio.

Step 2: Working with the activity_main.xml file

Navigate to app > res > layout > activity_main.xml and add the below code to it. Comments are added in the code to get to know in detail. 

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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">
 
    <!--edit text to enter amount-->
    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/idTILAmount"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="20dp"
        android:hint="Enter total amount to split"
        android:padding="5dp"
        android:textColorHint="@color/black"
        app:hintTextColor="@color/black">
 
        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/idEdtAMount"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:ems="10"
            android:importantForAutofill="no"
            android:inputType="phone"
            android:textColor="@color/black"
            android:textColorHint="@color/black"
            android:textSize="14sp" />
    </com.google.android.material.textfield.TextInputLayout>
 
    <!--edit text to enter number of person to split amount-->
    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/idTILPerson"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="20dp"
        android:hint="Enter number of people to split"
        android:padding="5dp"
        android:textColorHint="@color/black"
        app:hintTextColor="@color/black">
 
        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/idEdtPeople"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:ems="10"
            android:importantForAutofill="no"
            android:inputType="phone"
            android:textColor="@color/black"
            android:textColorHint="@color/black"
            android:textSize="14sp" />
    </com.google.android.material.textfield.TextInputLayout>
 
    <!--edit text to enter tip amount-->
    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/idTILTip"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="20dp"
        android:hint="Enter tip amount"
        android:padding="5dp"
        android:textColorHint="@color/black"
        app:hintTextColor="@color/black">
 
        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/idEdtTip"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:ems="10"
            android:importantForAutofill="no"
            android:inputType="phone"
            android:textColor="@color/black"
            android:textColorHint="@color/black"
            android:textSize="14sp" />
    </com.google.android.material.textfield.TextInputLayout>
 
    <!--button to get the amount for individual-->
    <Button
        android:id="@+id/idBtnGetAmount"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="20dp"
        android:layout_marginTop="10dp"
        android:layout_marginEnd="20dp"
        android:layout_marginBottom="10dp"
        android:padding="15dp"
        android:text="Get Amount"
        android:textAllCaps="false"
        android:textStyle="bold" />
 
    <!--button to reset -->
    <Button
        android:id="@+id/idBtnReset"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="20dp"
        android:layout_marginTop="10dp"
        android:layout_marginEnd="20dp"
        android:padding="15dp"
        android:text="Reset"
        android:textAllCaps="false"
        android:textStyle="bold" />
 
    <!-- text view to display amount for individual-->
    <TextView
        android:id="@+id/idTVIndividualAmount"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="20dp"
        android:padding="5dp"
        android:text="Individual Amount : "
        android:textAlignment="center"
        android:textAllCaps="false"
        android:textColor="@color/black"
        android:textSize="18sp"
        android:textStyle="bold" />
 
</LinearLayout>
                      
                       

Step 3: Working with the MainActivity file 

Navigate to app > java > your app’s package name > MainActivity file and add the below code to it. Comments are added in the code to get to know in detail. 

Kotlin

package com.gtappdevelopers.draganddrop
 
import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.google.android.material.textfield.TextInputEditText
 
class MainActivity : AppCompatActivity() {
 
    // creating variables for edit text, button and text views.
    lateinit var amountEdt: TextInputEditText
    lateinit var peopleEdt: TextInputEditText
    lateinit var tipEdt: TextInputEditText
    lateinit var amtBtn: Button
    lateinit var resetBtn: Button
    lateinit var amtTV: TextView
 
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
         
        // initializing variables with ids.
        amountEdt = findViewById(R.id.idEdtAMount)
        peopleEdt = findViewById(R.id.idEdtPeople)
        tipEdt = findViewById(R.id.idEdtTip)
        amtBtn = findViewById(R.id.idBtnGetAmount)
        resetBtn = findViewById(R.id.idBtnReset)
        amtTV = findViewById(R.id.idTVIndividualAmount)
 
        // adding click listener for amount button.
        amtBtn.setOnClickListener {
            // validating if edit text is not empty
            if (amountEdt.text.toString() != null && peopleEdt.text.toString() != null && tipEdt.text.toString() != null) {
                // adding number from amount and tip
                // and dividing it by number of people.
                val individualAmt: Int =
                    (Integer.parseInt(amountEdt.text.toString()) + Integer.parseInt(tipEdt.text.toString())) / Integer.parseInt(
                        peopleEdt.text.toString()
                    )
                // setting amount to text view.
                amtTV.text = "Individual Amount : \n" + individualAmt.toString()
            }
        }
 
        // adding click listener for reset button.
        resetBtn.setOnClickListener {
            // setting empty text for edit text.
            amountEdt.setText("")
            peopleEdt.setText("")
            tipEdt.setText("")
            amtTV.text = ""
        }
    }
}
                      
                       

Java

package com.gtappdevelopers.textencryptionjava;
 
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.material.textfield.TextInputEditText;
 
public class MainActivity extends AppCompatActivity {
    private TextInputEditText amountEdt, peopleEdt, tipEdt;
    private TextView amtTV;
    private Button resetBtn, amtBtn;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
         
        // initializing variables with ids.
        amountEdt = findViewById(R.id.idEdtAMount);
        peopleEdt = findViewById(R.id.idEdtPeople);
        tipEdt = findViewById(R.id.idEdtTip);
        amtBtn = findViewById(R.id.idBtnGetAmount);
        resetBtn = findViewById(R.id.idBtnReset);
        amtTV = findViewById(R.id.idTVIndividualAmount);
 
        // adding click listener for amount button.
        amtBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // validating if edit text is not empty
                if (amountEdt.getText().toString() != null && peopleEdt.getText().toString() != null && tipEdt.getText().toString() != null) {
                    // adding number from amount and tip
                    // and dividing it by number of people.
                    Integer individualAmt =
                            (Integer.parseInt(amountEdt.getText().toString()) + Integer.parseInt(tipEdt.getText().toString())) / Integer.parseInt(
                                    peopleEdt.getText().toString()
                            );
                    // setting amount to text view.
                    amtTV.setText("Individual Amount : \n" + individualAmt.toString());
                }
            }
        });
 
        // adding click listener for reset button.
        resetBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // setting empty text for edit text.
                amountEdt.setText("");
                peopleEdt.setText("");
                tipEdt.setText("");
                amtTV.setText("");
            }
        });
    }
}
                      
                       

Now run your application to see the output of it.

Output:

https://media.geeksforgeeks.org/wp-content/uploads/20221005132847/Screenrecorder-2022-10-05-13-23-33-669.mp4


Next Article
How to Build a Simple Notes App in Android?

C

chaitanyamunje
Improve
Article Tags :
  • Android
  • Java
  • Kotlin
  • Project
Practice Tags :
  • Java

Similar Reads

  • How to Build a Simple Magic 8 Ball App in Android?
    In this article, we will be building a Magic 8 Ball App Project using Java and XML in Android. The application is based on a decision making application. In this app, a user can ask the ball what decision they should make. The ball will randomly answer Yes, No, Not Sure, and other such answers. Ther
    3 min read
  • How to Build a Simple Notes App in Android?
    Notes app is used for making short text notes, updating when you need them, and trashing when you are done. It can be used for various functions as you can add your to-do list in this app, some important notes for future reference, etc. The app is very useful in some cases like when you want quick a
    9 min read
  • How to Build a Simple Swiping Game in Android?
    In this article, we are going to create a simple swiping game using RecyclerView in Android Studio. RecyclerView is the ViewGroup that contains the views corresponding to your data. It's a view itself, so you add RecyclerView into your layout the way you would add any other UI element. We are going
    6 min read
  • How to Build a Pomodoro App in Android?
    The Pomodoro Technique is a time management method developed by Francesco Cirillo in the late 1980s. The technique uses a timer to break down work into intervals, traditionally 25 minutes in length, separated by short breaks of 5 minutes. These intervals are known as "pomodoros". The method is based
    4 min read
  • How to Build a Simple Voice Typer App in Android using Java?
    Pre-requisites: Android App Development Fundamentals for BeginnersGuide to Install and Set up Android StudioHow to Create/Start a New Project in Android Studio?Running your first Android appSpinner in AndroidRecognizerIntent in Android In this article, we are going to build a simple Voice Typer app
    5 min read
  • How to Build a Weather App in Android?
    In this project, we will be building a weather application. This application will show the temperature of a location. To fetch weather information we will need an API. An API(Application Programming Interface) is a function that allows applications to interact and share data using various components
    6 min read
  • How to Build a Sudoku Solver Android App?
    In this article, we are going to make a sudoku solver Android app in Kotlin and xml. The main focus of the app will be on the sudoku-solving algorithm so the the design part has been hardcoded. A sample video is given below to get an idea about what we are going to do in this article. Step by Step I
    12 min read
  • How to Build a Simple Augmented Reality Android App?
    Augmented Reality has crossed a long way from Sci-fi Stories to Scientific reality. With this speed of technical advancement, it's probably not very far when we can also manipulate digital data in this real physical world as Tony Stark did in his lab. When we superimpose information like sound, text
    11 min read
  • How to Build a Simple Expense Calculator App in Android?
    Pre-requisites: Android App Development Fundamentals for BeginnersGuide to Install and Set up Android StudioHow to Create/Start a New Project in Android Studio?Running your first Android appRecyclerView in Android with ExampleShared Preferences in Android with Example A simple expense calculator let
    10 min read
  • How to Build a Rick and Morty App in Android?
    Rick and Morty is an American animated science fiction sitcom created by Justin Roiland and Dan Harmon. In this article, we will build an application that will display the name and image of all rick and Morty characters using this API. In order to build this application we will be using the Retrofit
    5 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences