Reputation: 69
It duplicates theTableRow
and displays it as shown in the image. Is there a more efficient way?
Also, are there any articles or sites where I can learn more about xml for creating Android layouts?
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#E3AFFA"
android:layout_margin="10dp"
tools:ignore="UselessParent">
<TableRow
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_weight="1"
android:radius="100dp"
>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:padding="1dp"
android:textSize="10dp"
android:layout_weight="5"
android:gravity="center_horizontal"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Sun"
android:textColor="@android:color/white"
android:padding="1dp"
android:textSize="10dp"
android:layout_weight="5"
android:gravity="center_horizontal"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Mon"
android:textColor="@android:color/white"
android:padding="1sp"
android:textSize="10dp"
android:layout_weight="5"
android:gravity="center_horizontal"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Tue"
android:textColor="@android:color/white"
android:padding="1sp"
android:textSize="10dp"
android:layout_weight="5"
android:gravity="center_horizontal"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Wed"
android:textColor="@android:color/white"
android:padding="1sp"
android:textSize="10dp"
android:layout_weight="5"
android:gravity="center_horizontal"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Thu"
android:textColor="@android:color/white"
android:padding="1sp"
android:textSize="10dp"
android:layout_weight="5"
android:gravity="center_horizontal"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Fri"
android:textColor="@android:color/white"
android:padding="1sp"
android:textSize="10dp"
android:layout_weight="5"
android:gravity="center_horizontal"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Sat"
android:textColor="@android:color/white"
android:padding="1sp"
android:textSize="10dp"
android:layout_weight="5"
android:gravity="center_horizontal"
/>
</TableRow>...
Upvotes: 0
Views: 37
Reputation: 26
The efficient way to produce a table is using Table layout with RecyclerView.
You can checkout the following link for complete understanding :
https://mustafaimran71.medium.com/table-layout-with-recycler-view-in-kotlin-d5224d8b8a34
Upvotes: 1