VOOZH about

URL: https://www.geeksforgeeks.org/android/how-to-change-the-shape-of-imagebutton-in-android/

⇱ How to Change the Shape of ImageButton in Android? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Change the Shape of ImageButton in Android?

Last Updated : 23 Jul, 2025

Android ImageButton is a user interface widget that is used to display a button having an image and to perform exactly like a button when we click on it but here, we add an image on the Image button instead of text. Below is a sample image of ImageButton.

👁 Image

In the android studio, the default shape of the ImageButton is square. In this article, we will see how to change the default shape from Square to the following shapes 

  1. Circular
  2. Rectangular
  3. Square with curved edges

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. Note that select Java as the programming language.

Step 2: Working with the activity_main.xml file

Navigate to the app > res > layout > activity_main.xml and add the below code to that file. Below is the code for the activity_main.xml file. Create a simple ImageButton in the activity_main.xml file. 

 
 

Step 3: Create Drawable Resource File 


 

Go to the app > res > drawbe > right-click > New > Drawable Resource File and name the file as custom_button1, custom_button2, cutom_button3 and apply them one by one in ImageButton like this:


 

  1. android:background="@drawable/custombutton1"
  2. android:background="@drawable/custombutton2"
  3. android:background="@drawable/custombutton3"


 

1. custombutton1.xml file (Circular) 


 

 
 

Output:


 

👁 Image
fig = circular image button 


 

2. custombutton2.xml file (Rectangular) 


 

 
 

Output:


 

👁 Image
fig = rectangular image button 


 

3. custombutton3.xml file (Square with curved edges)


 

 
 

Output:


 

👁 Image
fig = square with curved edges 


 

Comment
Article Tags:

Explore