StickyHeaders

StickyHeaders

项目地址:ShamylZakariya/StickyHeaders 

简介:Adapter and LayoutManager for Android RecyclerView which enables sticky header positioning.

更多:作者   提 Bug   

标签:

 

Adapter and LayoutManager for Android RecyclerView which enables sticky header positioning.


Download

minSdkVersion: 11

compile 'org.zakariya.stickyheaders:stickyheaders:0.7.6'

StickyHeaders are section headers in a recyclerview which are positioned "stickily" to the top of the scrollview during scrolling. A common use-case is an address book where the list of people's last names are grouped into sections by the first letter of the last name, and the header for each section shows that letter.

For example:

AddressBookSample

StickyHeaders also supports a callback (org.zakariya.stickyheaders.StickyHeaderLayoutManager.HeaderPositionChangedCallback) when a header becomes "sticky" or returns to normal positioning. For example, it is used here to set the elevation on the header to cast a subtle drop shadow when the header is in sticky position.

For example:

CallbacksSample

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在 Flutter 中,可以使用 `stickyHeaders` 参数来实现在 DataTable 中固定表头。设置 `stickyHeaders` 为 `true` 后,表头将会被固定在视图的顶部,当用户滚动表格内容时,表头不会跟随滚动而消失。 以下是一个示例代码: ```dart import 'package:flutter/material.dart'; class MyDataTable extends StatefulWidget { @override _MyDataTableState createState() => _MyDataTableState(); } class _MyDataTableState extends State<MyDataTable> { final List<Map<String, String>> dataList = [ { 'name': 'John Smith', 'age': '30', 'email': 'john.smith@example.com', }, { 'name': 'Jane Doe', 'age': '25', 'email': 'jane.doe@example.com', }, { 'name': 'Bob Johnson', 'age': '40', 'email': 'bob.johnson@example.com', }, ]; @override Widget build(BuildContext context) { return SingleChildScrollView( scrollDirection: Axis.vertical, child: SingleChildScrollView( scrollDirection: Axis.horizontal, child: DataTable( columns: [ DataColumn( label: Text('Name'), ), DataColumn( label: Text('Age'), ), DataColumn( label: Text('Email'), ), ], rows: dataList .map( (data) => DataRow( cells: [ DataCell(Text(data['name'])), DataCell(Text(data['age'])), DataCell(Text(data['email'])), ], ), ) .toList(), // 设置 stickyHeaders 为 true stickyHeaderRows: 1, ), ), ); } } ``` 在上面的示例代码中,我们通过设置 `stickyHeaderRows` 参数为 `1` 来实现固定表头。这个参数表示表头占据的行数,如果有多行表头,需要设置为对应的行数。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值