android怎么做表格顯示數據


實現思路:最底層(父級)背景為黑色,最上層(子級)背景為白色,然后父子組件之間存在一絲間隔即可顯示出類似邊框的線。

本次主要利用Android中的TableRow等實現,其他類比也可以實現效果。

<TableLayout android:layout_width="350dp" android:layout_height="wrap_content" android:layout_marginTop="50dp" android:background="#000000" android:gravity="center">

        <TableRow android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:padding="1dp">

            <TextView android:id="@+id/textView14" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="#FFFFFF" android:gravity="center" android:text="車輛ID" android:textColor="#000000" android:textSize="18sp" android:textStyle="bold" />

            <TextView android:id="@+id/textView13" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginLeft="1dp" android:layout_marginRight="1dp" android:layout_weight="1" android:background="#FFFFFF" android:gravity="center" android:text="充值金額" android:textColor="#000000" android:textSize="18sp" android:textStyle="bold" />

            <TextView android:id="@+id/textView12" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="#FFFFFF" android:gravity="center" android:text="充值時間" android:textColor="#000000" android:textSize="18sp" android:textStyle="bold" />
        </TableRow>

    </TableLayout>

效果:
在這里插入圖片描述

另外,也可以使用ListView實現。

感謝大佬:https://jingyan.baidu.com/article/c74d6000dea5ec0f6a595dda.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM