-
-
Save codingwithsara/1f517cd97e2f842de24c0089d79654c9 to your computer and use it in GitHub Desktop.
【Android Studio Tips】TableLayout – Border & Collapse –
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical" | |
android:background="#ffffff" | |
tools:context=".MainActivity"> | |
<TableLayout | |
android:id="@+id/table" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginVertical="30dp" | |
android:layout_marginHorizontal="10dp" | |
android:background="#f1f1f1" | |
android:collapseColumns="1,2"> | |
<TableRow> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Name" | |
android:textStyle="bold" | |
android:layout_weight="1" | |
android:gravity="center"/> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Email" | |
android:textStyle="bold" | |
android:layout_weight="1" | |
android:gravity="center"/> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Tel" | |
android:textStyle="bold" | |
android:layout_weight="1" | |
android:gravity="center"/> | |
</TableRow> | |
<TableRow> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Alice" | |
android:layout_weight="1" | |
android:gravity="center" | |
android:background="#ffffff" | |
android:layout_marginBottom="1dp" | |
android:layout_marginHorizontal="1dp"/> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="a@a.com" | |
android:layout_weight="1" | |
android:gravity="center" | |
android:background="#ffffff" | |
android:layout_marginRight="1dp" | |
android:layout_marginBottom="1dp"/> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="111-111" | |
android:layout_weight="1" | |
android:gravity="center" | |
android:background="#ffffff" | |
android:layout_marginRight="1dp" | |
android:layout_marginBottom="1dp"/> | |
</TableRow> | |
<TableRow> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Bob" | |
android:layout_weight="1" | |
android:gravity="center" | |
android:background="#ffffff" | |
android:layout_marginBottom="1dp" | |
android:layout_marginHorizontal="1dp"/> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="b@b.com" | |
android:layout_weight="1" | |
android:gravity="center" | |
android:background="#ffffff" | |
android:layout_marginRight="1dp" | |
android:layout_marginBottom="1dp"/> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="222-222" | |
android:layout_weight="1" | |
android:gravity="center" | |
android:background="#ffffff" | |
android:layout_marginRight="1dp" | |
android:layout_marginBottom="1dp"/> | |
</TableRow> | |
<TableRow> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Carey" | |
android:layout_weight="1" | |
android:gravity="center" | |
android:background="#ffffff" | |
android:layout_marginBottom="1dp" | |
android:layout_marginHorizontal="1dp"/> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="c@c.com" | |
android:layout_weight="1" | |
android:gravity="center" | |
android:background="#ffffff" | |
android:layout_marginRight="1dp" | |
android:layout_marginBottom="1dp"/> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="333-333" | |
android:layout_weight="1" | |
android:gravity="center" | |
android:background="#ffffff" | |
android:layout_marginRight="1dp" | |
android:layout_marginBottom="1dp"/> | |
</TableRow> | |
</TableLayout> | |
<Button | |
android:id="@+id/switchBtn" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Show Detail" | |
android:textAllCaps="false" | |
android:layout_gravity="center" | |
android:onClick="collapseTable"/> | |
</LinearLayout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment