Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7852439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:25:04+00:00 2026-06-02T19:25:04+00:00

I have two image buttons, button1 and button2. For button1, I am setting a

  • 0

I have two image buttons, button1 and button2. For button1, I am setting a bigger image and for button2 I am setting a small image. I have to place button2 exactly at the center of button1. How do I achieve this?

I am using relative layout and I have to do this changes in an XML file. I need to receive click events also separately for both the buttons.

I have tried the below code, but I am not receiving separate click events.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:id="@+id/linearLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:src="@drawable/mainscreen"
        android:scaleType="fitXY" />

    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="320dp"
        android:layout_height="50dp"
        ads:adUnitId="xxxx"
        ads:adSize="BANNER"
        ads:loadAdOnCreate="true"/>

    <ImageButton android:id="@+id/star"
        android:layout_width ="wrap_content"
        android:layout_height ="wrap_content"
        android:layout_toRightOf="@+id/adView"
        android:src="@drawable/star"
        android:background="@layout/selector"
        android:layout_marginLeft="40dp"
        android:focusable="false" />

    <ImageButton android:id="@+id/image1"
        android:layout_width ="wrap_content"
        android:layout_height ="wrap_content"
        android:layout_below="@+id/adView"
        android:src="@drawable/drum"
        android:background="@layout/selector"
        android:layout_marginTop="30dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="10dp"
        android:focusable="false" />
    <ImageButton android:id="@+id/image2"
        android:layout_width ="wrap_content"
        android:layout_height ="wrap_content"
        android:src="@drawable/drum1"
        android:layout_alignLeft="@+id/image1"
        android:layout_alignTop="@+id/image1"
        android:layout_alignRight="@+id/image1"
        android:layout_alignBottom="@+id/image1"
        android:focusable="false" />

    <ImageButton android:id="@+id/image3"
        android:layout_width ="wrap_content"
        android:layout_height ="wrap_content"
        android:src="@drawable/drum2"
        android:background="@layout/selector"
        android:layout_alignLeft="@+id/image1"
        android:layout_alignTop="@+id/image1"
        android:layout_alignRight="@+id/image1"
        android:layout_alignBottom="@+id/image1"
        android:focusable="false" />

    <ImageButton android:id="@+id/image4"
        android:layout_width ="wrap_content"
        android:layout_height ="wrap_content"
        android:layout_below="@+id/adView"
        android:src="@drawable/drum"
        android:background="@layout/selector"
        android:layout_marginTop="30dp"
        android:layout_toRightOf="@+id/image1"
        android:focusable="false" />

    <ImageButton android:id="@+id/image5"
        android:layout_width ="wrap_content"
        android:layout_height ="wrap_content"
        android:src="@drawable/drum1"
        android:background="@layout/selector"
        android:layout_alignLeft="@+id/image4"
        android:layout_alignTop="@+id/image4"
        android:layout_alignRight="@+id/image4"
        android:layout_alignBottom="@+id/image4"
        android:focusable="false" />

    <ImageButton android:id="@+id/image6"
        android:layout_width ="wrap_content"
        android:layout_height ="wrap_content"
        android:src="@drawable/drum2"
        android:background="@layout/selector"
        android:layout_alignLeft="@+id/image4"
        android:layout_alignTop="@+id/image4"
        android:layout_alignRight="@+id/image4"
        android:layout_alignBottom="@+id/image4"
        android:focusable="false" />
</RelativeLayout>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:25:07+00:00Added an answer on June 2, 2026 at 7:25 pm

    With your current layout, you will need to nest the items. but since you’re only interested in the image part of the imagebutton, you can just use a FrameLayout for what you’re currently calling “button1” like in my example (adapt to your circumstances):

    <FrameLayout android:id="@+id/button1"
      ...
      android:background="@drawable/image1"
      >
    
      <ImageButton
        android:id="@+id/button2"
        android:layout_gravity="center"
        android:src="@drawable/image2" />
    
    </FrameLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MasterPage that has two image buttons , and two content pages,
I have two side borders on my website, left and right side... small image
I have a screen with a background image and two buttons at the bottom.
Well I have two buttons, each image in a span, and one should be
I have a search textbox and two image buttons on a page I created
i have two buttons in menu on mouse over the button change image to
I have an image which I am processing, and I have two buttons, undo
I have two image buttons with Click events assigned to them. There is code
So I have two buttons in the leftBarButtonItem. This is my code. NSString *todayString
I have a header for a list that contains two image buttons. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.