У меня есть набор кнопок в GridLayout
, высота кнопок пропорциональна их ширине, ширина кнопки - почти половина ширины сетки (0dp & weight).Теперь я хочу установить высоту GridLayout
для wrap_content, но он ничего не рендерит, если я установлю GridLayout's
height на match_parent
, то он отобразится.
Мой код:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".Home"
tools:showIn="@layout/app_bar_home">
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
android:columnCount="2"
android:rowCount="3"
>
<ImageButton
android:layout_width="0dp"
android:layout_height="0dp"
android:src="@drawable/btn_home_selection"
style="@style/home_button_style"
/>
<ImageButton
android:layout_width="0dp"
android:layout_height="0dp"
android:src="@drawable/btn_home_selection"
style="@style/home_button_style"
/>
<ImageButton
android:layout_width="0dp"
android:layout_height="0dp"
android:src="@drawable/btn_home_selection"
style="@style/home_button_style"
/>
<ImageButton
android:layout_width="0dp"
android:layout_height="0dp"
android:src="@drawable/btn_home_selection"
style="@style/home_button_style"
/>
<ImageButton
android:layout_width="0dp"
android:layout_height="0dp"
android:src="@drawable/btn_home_selection"
style="@style/home_button_style"
/>
<ImageButton
android:layout_width="0dp"
android:layout_height="0dp"
android:src="@drawable/btn_home_selection"
style="@style/home_button_style"
/>
</GridLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
![enter image description here](https://i.stack.imgur.com/ZJKU5.png)