Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<ol> <li>Have a horizontal <code>LinearLayout</code> as a child of the <code>RelativeLayout</code> and add the <code>ToggleButton</code> and <code>ImageView</code> to it.</li> <li>For the <code>ToggleButton</code> set <code>android:layout_height="match_parent"</code>.</li> </ol> <p><strong>Edit:</strong><br> Here's the working code:</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingLeft="5dip" android:paddingRight="5dip" android:paddingBottom="10dip" &gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" &gt; &lt;ToggleButton android:id="@+id/buttonView" android:layout_width="wrap_content" android:layout_height="match_parent" android:textOff="View" android:textOn="Hide" /&gt; &lt;ImageButton android:id="@+id/imageButton" android:layout_width="wrap_content" android:layout_height="match_parent" android:src="@drawable/copy" /&gt; &lt;/LinearLayout&gt; &lt;/RelativeLayout&gt; </code></pre> <p><strong>Edit2:</strong> </p> <p>Understood your problem. The above code <em>appears</em> to work only on Android 4.0, with the default Holo theme. </p> <p>On Android 2.3, in the default theme, the style of <code>ImageButton</code> specifies the background as <a href="https://github.com/android/platform_frameworks_base/blob/master/core/res/res/drawable-hdpi/btn_default_normal.9.png" rel="nofollow"><code>btn_default_normal</code></a>, in which the top row of pixels is transparent. Whereas the <code>ToggleButton</code>'s background for the same theme uses <a href="https://github.com/android/platform_frameworks_base/blob/master/core/res/res/drawable-hdpi/btn_default_small_normal.9.png" rel="nofollow"><code>btn_default_small_normal</code></a>, which has opaque pixels on the top row. (Click on the links to check for yourself.)</p> <p>Hence, when placed alongside a <code>ToggleButton</code>, they don't <em>appear</em> to have the same height.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload