c# - How to use TableLayout to create the design i want? -
help using tablelayout & tablerow, in picture below trying marge no.4 , no.6 no.1 had no idea how it. no.1 able cause using layout-weight divide screen 3row,3col .
<tablelayout android:layout_width="match_parent" android:layout_height="match_parent" android:stretchcolumns="*"> <tablerow android:layout_weight="2" android:id="@+id/tablerow1"> <textview android:text="1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" android:background="@android:color/holo_blue_dark" /> <tablelayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_span="2" android:stretchcolumns="*" android:id="@+id/tablelayout1"> <tablerow android:layout_weight="1" android:id="@+id/tablerow1" android:background="@android:color/holo_red_dark"> <textview android:text="2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_span="2" android:gravity="center" /> </tablerow> <tablerow android:layout_weight="1" android:id="@+id/tablerow3"> <textview android:text="3" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" /> <textview android:text="4" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" /> </tablerow> </tablelayout> </tablerow> <tablerow android:layout_weight="1" android:id="@+id/tablerow1"> <textview android:text="5" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_span="2" android:gravity="center" android:background="@android:color/holo_green_dark" /> <textview android:text="6" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="right" /> </tablerow>
use gridlayout
. try following code
<?xml version="1.0" encoding="utf-8"?> <gridlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:padding="5dp" android:rowcount="3" android:columncount="3" android:layout_height="wrap_content"> <button android:text="1" android:layout_height="wrap_content" android:layout_gravity="fill_vertical" android:layout_rowspan="2" android:layout_width="wrap_content" android:background="#abc012"/> <button android:text="2" android:layout_columnspan="2" android:layout_gravity="fill_horizontal" android:layout_height="wrap_content" android:layout_width="wrap_content" android:background="#a01012"/> <button android:text="3" android:layout_gravity="fill" android:layout_height="wrap_content" android:layout_width="wrap_content" android:background="#10fa5c"/> <button android:text="4" android:layout_rowspan="2" android:layout_gravity="fill_vertical" android:layout_height="wrap_content" android:layout_width="wrap_content" android:background="#9d34a1"/> <button android:text="5" android:layout_gravity="fill_horizontal" android:layout_columnspan="2" android:layout_height="wrap_content" android:layout_width="wrap_content" android:background="#f0f53f"/> </gridlayout>
screen shot
edit 1
just replace
android:layout_height="match_parent"
instead of
android:layout_height="wrap_content"
in <gridlayout>
. output follow as,
Comments
Post a Comment