Abhi Abhi - 18 days ago 5
Android Question

Which Layout GridLayout or TableLayout is suitable for this type of UI in Android

enter image description here

I wrote this xml in Screenlayout.xml

<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content">
<LinearLayout android:paddingLeft="10dp" android:layout_width="match_parent" android:background="@android:color/transparent" android:layout_height="50dp">
<TextView android:layout_width="wrap_content" android:gravity="center_vertical"
android:layout_height="match_parent" android:text="Total (In USD)" android:textColor="#696969"/>
</LinearLayout>
</LinearLayout>
<GridLayout android:orientation="horizontal" android:layout_width="match_parent"
android:stretchMode="columnWidth" android:columnCount="2" android:rowCount="3"
android:layout_height="50dp" android:background="#696969">
<LinearLayout android:layout_margin="1dp" android:layout_row="0" android:layout_column="0"
android:background="#FFFFFF" android:orientation="vertical" android:layout_height="48dp" android:layout_width="wrap_content">
<TextView android:layout_width="wrap_content" android:gravity="center_vertical"
android:textSize="13dp" android:layout_height="wrap_content" android:text="Contract Amount" android:textColor="#9E9E9E"/>
<TextView android:layout_width="wrap_content" android:gravity="center_vertical"
android:layout_height="wrap_content" android:textStyle="bold" android:text="4523452345234" android:textColor="#696969"/>
</LinearLayout>
<LinearLayout android:layout_row="0" android:layout_column="1"
android:layout_margin="1dp" android:background="#FFFFFF" android:orientation="vertical" android:layout_height="48dp" android:layout_width="wrap_content">
<TextView android:layout_width="wrap_content" android:gravity="center_vertical"
android:textSize="13dp" android:layout_height="wrap_content" android:text="Actual Amount" android:textColor="#9E9E9E"/>
<TextView android:layout_width="wrap_content" android:gravity="center_vertical"
android:layout_height="wrap_content" android:textStyle="bold" android:text="45243" android:textColor="#696969"/>
</LinearLayout>
</GridLayout>


enter image description here

But sadly this is the UI it is producing..
What is the best option to achieve this

Answer

Table layout is generally used for these types of layout.

Refer this for your question.

https://www.tutorialspoint.com/android/android_table_layout.htm.