VOOZH about

URL: https://www.geeksforgeeks.org/android/how-to-build-spin-the-bottle-game-application-in-android/

⇱ How to Build Spin the Bottle Game Application in Android? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Build Spin the Bottle Game Application in Android?

Last Updated : 23 Jul, 2025

In this article, we will be building a Spin the Bottle Game Project using Java/Kotlin and XML in Android. The application is based on a multiplayer game. One player spins the bottle and the direction in which the bottle spins will determine the player who gets selected for a task or any other stuff. There will be a single activity in this application.

👁 How-to-Build-Spin-the-Bottle-Game-Application-in-Android_


Step by Step Implementation

Step 1: Create a New Project

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

Step 2: Import bottle image

Go to app > res > drawable and add this bottle image.

Step 3: Working with the activity_main.xml file

The XML codes are used to build the structure of the activity as well as its styling part. It contains a TextView at the very top of the activity to show the title. Then it contains an ImageView of the bottle in the center of the activity. Below is the code for the activity_main.xml file.

activity_main.xml:


Step 4: Working with the MainActivity file

We will set an onClickListener on the bottle to rotate the bottle when the bottle in tapped. Then, we will create a spinBottle() function to write the code for spinning the bottle. Inside this function, we will generate a random number from 5-10 that will be the number of the times the bottle spins. For this, we will be using the Random function. We will use ObjectAnimator to spin the image. We can set a duration of the animation. We will also use DecelerateInterpolator() to slow down the bottle naturally.

MainActivity File:

Output:


Comment

Explore