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:

As you see, ToggleButton aligned incorrectly, it’s always little higher than ImageButton. What am I doing wrong?
Testing on Android 2.3
Try like this..
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