您的位置:首页 > 移动开发 > Android开发

Listview高级标签使用transcriptMode,stackFromBottom

2015-12-24 14:09 706 查看
在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”:从底部开始填充
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android listview xml