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 9155313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:34:10+00:00 2026-06-17T12:34:10+00:00

I have a RelativeLayout with one ImageButton , one ToggleButton and some other controls.

  • 0

I have a RelativeLayout with one ImageButton, one ToggleButton and some other controls. Both buttons aligned on the right of the RelativeLayout. I want them to have the same height. Here is my layout xml:

<RelativeLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="5dip"
    android:paddingRight="5dip"
    android:paddingBottom="10dip" >

    <ImageButton
        android:id="@+id/imageButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/copy"
        android:layout_alignParentRight="true" />

    <ToggleButton
        android:id="@+id/buttonView"
        android:layout_width="wrap_content"
        android:layout_height="0dip"
        android:textOn="Hide"
        android:textOff="View" 
        android:layout_toLeftOf="@id/imageButton" 
        android:layout_alignTop="@id/imageButton"
        android:layout_alignBottom="@id/imageButton" />

    <!-- ... other controls ... -->
</RelativeLayout>

I tried to set layout_height="0dip" and used layout_alignTop and layout_alignBottom to make ToggleButton to have the same height as ImageButton, but this doesn’t work:

enter image description here

As you see, ToggleButton aligned incorrectly, it’s always little higher than ImageButton. What am I doing wrong?

Testing on Android 2.3

  • 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-17T12:34:12+00:00Added an answer on June 17, 2026 at 12:34 pm

    Try like this..

             <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingBottom="10dip"
            android:paddingLeft="5dip"
            android:paddingRight="5dip" >
    
        <ImageButton
            android:id="@+id/imageButton"
            android:layout_width="55dp"
            android:layout_height="55dp"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:src="@drawable/ic_launcher" />
    
        <ToggleButton
            android:id="@+id/buttonView"
            android:layout_width="55dp"
            android:layout_height="54dp"
            android:layout_alignTop="@id/imageButton"
            android:layout_toLeftOf="@+id/imageButton"
            android:textOff="View"
            android:textOn="Hide" />
    
        <!-- ... other controls ... -->
    </RelativeLayout>
    

    Toggle button will be little bit more height than compare to image button you have to increase the width and height for the image button than it will be perfect ,using same width and height little difference you can find

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ImageButton that I want to fill its parent RelativeLayout container for
I have a RelativeLayout in which i have one ImageButton. I need the position
Right now, I have two TextView 's. One is aligned to the left of
I have a ScrollView on one of my screens. I want the right edge
I have a RelativeLayout that holds some views. One of the views is MapView
I have one RelativeLayout in which i have 5 buttons, I hide this RelativeLayout
I have a RadioGroup and I want to align buttons next to each other
I have a RelativeLayout with one child as <include another.xml> like this root.xml :
In this layout I have two Views - the ImageButton at bottom right and
I have complex view with more linearlayout-s and relativelayout in one child in ViewFlipper.

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.