У меня есть TableLayout, встроенный в HorizontalScrollView.Некоторые столбцы скрыты (android:visibility="gone"
).Однако, хотя у меня есть android:stretchColumns="*"
на TableLayout, столбцы не растягиваются на полную ширину.Вот что я получаю:
<-----------------Screen Width---------------->
<---------HorizontalScrollView Width---------->
<---------TableLayout Width------------------->
<---------TableRow Width---------------------->
<-Col1-Col2-Col3-Col4-Col5->
Есть идеи, как это исправить?Если я физически удаляю из макета XML столбцы gone
(Col6-> Col9), то это выглядит так, как ожидалось.Однако каким-то образом установка столбцов в исходное состояние помешала работе stretchColumns.
<HorizontalScrollView
android:layout_width="match_parent"
android:fillViewport="true"
android:layout_height="wrap_content">
<TableLayout
android:stretchColumns="*"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:layout_width="match_parent"
android:layout_height="35dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="Col1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="Col2"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="Col3"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="Col4"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="Col5"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="35dp"
android:visibility="gone"
android:text="Col6"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="35dp"
android:visibility="gone"
android:text="Col7"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="35dp"
android:visibility="gone"
android:text="Col8"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="35dp"
android:visibility="gone"
android:text="Col9"/>
</TableRow>
</TableLayout>
</HorizontalScrollView>