android - layout_width in table row -
i have tablelayout multiple rows. rows may have 2 or 3 elements.
<tablelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <tablerow android:layout_height="wrap_content" android:layout_width="match_parent" android:weightsum="2"> <textview android:layout_height="wrap_content" android:layout_width="0dp" android:layout_weight="1" android:text="@string/spielfortsetzung" /> <textview android:layout_height="wrap_content" android:layout_width="0dp" android:layout_weight="1" android:text="@string/loesung" /> </tablerow> <tablerow android:layout_height="wrap_content" android:layout_width="match_parent"> <textview android:id="@+id/tv3" android:layout_height="wrap_content" android:layout_width="0dp" android:layout_weight="1" /> <listview android:id="@+id/list1" android:layout_height="wrap_content" android:layout_width="0dp" android:layout_weight="1" android:scrollbars="none" /> <imageview android:id="@+id/img1" android:layout_width="25dp" android:layout_height="25dp" /> </tablerow> </tablelayout>
in android studio layouts correct, not on device, when run app. there layouts have minimal space 1-2characters. doesn't use whole width, leaves space on left.
try this,
<tablerow android:layout_height="wrap_content" android:layout_width="match_parent"> <textview android:layout_height="wrap_content" android:layout_width="0dp" android:layout_weight="0.5" android:text="@string/spielfortsetzung" /> <textview android:layout_height="wrap_content" android:layout_width="0dp" android:layout_weight="0.5" android:text="@string/loesung" />
//same other rows , define weight portion .