TableView框架Android中以表格的样式展示简单的统计数据

借鉴GitHub:https://github.com/smartown/TableView

一、效果展示

二、下载源码,打开导入以下代码

1. TableView类;

2.  Util类;

3. values中的attrs.xml文件。

三、布局实现功能

<com.smartown.tableview.library.TableView
    android:id="@+id/table"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:layout_margin="8dp"
    app:dividerColor="#e1e1e1"
    app:dividerWidth="1px"
    app:headerColor="#00ffffff"
    app:headerTextColor="#111111"
    app:headerTextSize="10dp"
    app:rowHeight="36dp"
    app:textColor="#999999"
    app:textSize="10dp"
    app:unitColumnWidth="0dp" />
属性名含义默认值备注
dividerColor分割线颜色#e1e1e1 
dividerWidth分割线宽度1px 
headerColor表头背景颜色透明 
headerTextColor表头文字颜色#111111 
headerTextSize表头文字大小10dp 
rowHeight单元格高度36dp 
textColor表格内容文字颜色#999999 
textSize表格内容文字大小10dp 
unitColumnWidth单元格宽度0dp为0时会自动根据列数等分控件宽度

四、展示数据

tableView.clearTableContents()
                .setHeader("区域", "人数", "占比")
                .addContent("北京", "50", "50%")
                .addContent("上海", "30", "30%")
                .addContent("广东", "20", "20%")
                .addContent("深圳", "10", "10%")
                .refreshTable();

 

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值