У меня есть GridLayout с одной строкой и 5 столбцами. Элементами являются TextViews с верхним составным изображением для каждого. Я пытаюсь распределить эти столбцы равномерно, но это не будет сделано, потому что тексты даже не имеют длины.
<GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_double"
android:columnCount="9"
android:orientation="horizontal"
android:rowCount="1">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/ubrugeligText"
style="@style/TextAppearance.Body2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_columnWeight="1"
android:drawableTop="@drawable/ic_survey_ubrugelig_active"
android:drawablePadding="@dimen/layout_margin_half"
android:gravity="center_horizontal"
android:text="@string/tdc_app_survey_survey_rating_1" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/daarligText"
style="@style/TextAppearance.Body2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_columnWeight="1"
android:drawableTop="@drawable/ic_survey_daarlig_active"
android:drawablePadding="@dimen/layout_margin_half"
android:gravity="center_horizontal"
android:text="@string/tdc_app_survey_survey_rating_2" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/neutralText"
style="@style/TextAppearance.Body2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_columnWeight="1"
android:drawableTop="@drawable/ic_survey_neutral_active"
android:drawablePadding="@dimen/layout_margin_half"
android:gravity="center_horizontal"
android:text="@string/tdc_app_survey_survey_rating_3" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/godText"
style="@style/TextAppearance.Body2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_columnWeight="1"
android:drawableTop="@drawable/ic_survey_god_active"
android:drawablePadding="@dimen/layout_margin_half"
android:gravity="center_horizontal"
android:text="@string/tdc_app_survey_survey_rating_4" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/perfektText"
style="@style/TextAppearance.Body2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_columnWeight="1"
android:drawableTop="@drawable/ic_survey_perfekt_active"
android:drawablePadding="@dimen/layout_margin_half"
android:gravity="center_horizontal"
android:text="@string/tdc_app_survey_survey_rating_5" />
</GridLayout>
Я пытался использовать TableView (который основан на LinearLayouts), но получаю тот же результат, что можно увидеть ниже. Как сделать так, чтобы столбцы были равномерно распределены по ширине, о которой я знаю, что layoutWeight
должен заботиться, а не?
