VOOZH about

URL: https://www.geeksforgeeks.org/kotlin/icon-toggle-button-in-android-using-jetpack-compose/

⇱ Icon Toggle Button in Android using Jetpack Compose - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Icon Toggle Button in Android using Jetpack Compose

Last Updated : 23 Jul, 2025

Toggle Buttons are used in most applications. These buttons are used to perform multiple operations. Toggle buttons are seen used in many social media applications such as Instagram. In social media apps, we can get to see a heart icon that is used to like the image. We can also unlike that image by clicking on the same icon. In this article, we will look at How to Create an Icon Toggle Button in Android using Jetpack Compose.

A sample gif is given below to get an idea about what we are going to do in this article.

👁 icon-toogle-button


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. While choosing the template, select Empty Compose Activity. If you do not find this template, try upgrading the Android Studio to the latest version.

We demonstrated the application in Kotlin, so make sure you select Kotlin as the primary language while creating a New Project.

Step 2: Working with the MainActivity.kt file

Go to the MainActivity.kt file and refer to the following code. Below is the code for the MainActivity.kt file. Comments are added inside the code to understand the code in more detail.

MainActivity.kt:

Output:

Comment
Article Tags:

Explore