Android – how do I set the same height in relativelayout?

Here is my XML code:

<RelativeLayout
    android:id="@+id/ib"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:gravity="center" >

    <ImageButton
        android:id="@+id/button_icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <TextView
        android:id="@+id/tv"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_toLeftOf="@+id/ib"
        android:gravity="center"
        android:text="Large Text"
        android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>

Imagebutton IB and TextView TW have different heights. I want IB and TV to have the same height. That is, if IB height > TV, then set the TV height to be the same as IB. if not, set IB height to be the same as TV. What should I do?

resolvent:

Use LinearLayout and set the imagebutton height to "wrap_content" and the textview height to "fill_parent"

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>