Listview高级标签使用transcriptMode,stackFromBottom

在Listview中使用一些高级标签来满足一些特殊的需求。

android:transcriptMode

Sets the transcript mode for the list. In transcript mode, the list scrolls to the bottom to make new items visible when they are added.

Must be one of the following constant values.

ConstantValueDescription
disabled0Disables transcript mode. This is the default value.
normal1The list will automatically scroll to the bottom when a data set change notification is received and only if the last item is already visible on screen.
alwaysScroll2The list will automatically scroll to the bottom, no matter what items are currently visible.

这个是官方API文档的描述,android:transcriptMode本人的理解就是用来设置Listview自动滚动到底部的类型。
- disabled就是默认,不会自动滚动到底部
- normal 当键盘弹出时会自动滚动到底部,调用notifyDataSetChanged是不会自动滚动的。(这个适合聊天页面使用)
- alwaysScroll默认滚动到底部,键盘弹出和调用notifyDataSetChanged都会自动滚动到底部

android:stackFromBottom

Used by ListView and GridView to stack their content from the bottom.
Must be a boolean value, either “true” or “false”.
This may also be a reference to a resource (in the form “@[package:]type:name”) or theme attribute (in the form “?[package:][type:]name”) containing a value of this type.
This corresponds to the global attribute resource symbol stackFromBottom.
这个参数有两个选择,
-“false”:默认选择,Listview将从顶部开始填充
-“true”:从底部开始填充

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值