Увеличивать высоту элементов по самой высокой

Есть например

<LinearLayout
    android:id="@+id/iGroup"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <RoundButton
        android:id="@+id/iInformationBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:title="@string/map_menu_info_btn_title"
        app:description="@string/map_menu_info_btn_description"
        app:icon="@drawable/info_type_info_icon"/>

    <RoundButton
        android:id="@+id/iTrackBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:title="@string/map_menu_track_btn_title"
        app:description="@string/map_menu_track_btn_description"
        app:icon="@drawable/info_type_track_icon"/>

    <RoundButton
        android:id="@+id/iReportBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:title="@string/map_menu_info_btn_report"
        app:description="@string/map_menu_report_btn_description"
        app:icon="@drawable/info_type_telemetry_icon"/>

</LinearLayout>

Но размеры у RoundButton могут отличаться при смене языка или каких то других конфигураций (и не факт что всегда вторя кнопка будет самой высокой).

Как можно сделать так чтобы высота (height) кнопок всегда подстраивались по самой максимальной из всех этих кнопок?

введите сюда описание изображения


Ответы (2 шт):

Автор решения: Vadik

Можно сделать следующим образом, выставить match_parent в качестве ширины контейнера. А для всех кнопок выставить layout_width=0 и layout_weight=1.

Например,

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#ebaeba"
    android:orientation="horizontal">

    <Button
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Asdf asdfasdf asd sad fsad" />

    <Button
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Asdf asdfasdf asd sad fsad fsd fas dfasdfja lfdshf " />

    <Button
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Asdf asdfasdf asd sad fsad" />

</LinearLayout>

Результат будет таким:

три кнопки

UPD:

Как подсказывает tiarait, если нужно чтобы высота кнопок в итоге была одинаковой, то нужно также выставить каждой кнопке match_parent по высоте.

Тогда результат будет таким:

три кнопки одинаковые по высоте

→ Ссылка
Автор решения: Tiarait

На самом деле Vadik был почти прав, единственное layout_height у Button должен быть match_parent. И этот код работает если ширина Button известна заранее, в противном случае попробуйте этот вариант

<LinearLayout
    android:id="@+id/iGroup"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <Button
        android:layout_margin="2dp"
        android:layout_weight="1"
        android:id="@+id/iInformationBtn"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:text="Asdf asdfasdf"/>

    <Button
        android:layout_margin="2dp"
        android:layout_weight="1"
        android:id="@+id/iTrackBtn"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:text="Asdf asdfasdf asd sad fsad  asdfasdf asd sad fsad "/>

    <Button
        android:layout_margin="2dp"
        android:layout_weight="1"
        android:id="@+id/iReportBtn"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:text="Asdf asdfasdf asd sad fsad "/>

</LinearLayout>

введите сюда описание изображения

а вот тот же код где у Button layout_height = wrap_content

введите сюда описание изображения

→ Ссылка