首先将 ListView 项目添加到列表底部
Add ListView items to bottom of list first
我正在构建一个实现聊天功能的 android 应用程序。我目前聊天有效。然而,第一条消息出现在 ListView
的顶部,我想让聊天从底部到顶部增长,而不是从上到下增长。这可能吗?我知道像 Periscope 和 Meerkat 这样的应用程序都会这样做,但我不确定它是否与 ListView
设置listView.setStackFromBottom(真);为您的 ListView。
From the doc : public void setStackFromBottom (boolean stackFromBottom)
When stack from bottom is set to true, the list fills its content
starting from the bottom of the view
除了 dhaval patel 的回答。如果您希望列表视图在调用 notifydatasetchanged 时自动向下滚动到底部,您还可以将转录模式设置为始终滚动。如果你不想这样,你可以将 transcriptmode 设置为正常。您可以通过列表视图
的 xml 对其进行编码
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll"
我正在构建一个实现聊天功能的 android 应用程序。我目前聊天有效。然而,第一条消息出现在 ListView
的顶部,我想让聊天从底部到顶部增长,而不是从上到下增长。这可能吗?我知道像 Periscope 和 Meerkat 这样的应用程序都会这样做,但我不确定它是否与 ListView
设置listView.setStackFromBottom(真);为您的 ListView。
From the doc : public void setStackFromBottom (boolean stackFromBottom)
When stack from bottom is set to true, the list fills its content starting from the bottom of the view
除了 dhaval patel 的回答。如果您希望列表视图在调用 notifydatasetchanged 时自动向下滚动到底部,您还可以将转录模式设置为始终滚动。如果你不想这样,你可以将 transcriptmode 设置为正常。您可以通过列表视图
的 xml 对其进行编码android:stackFromBottom="true"
android:transcriptMode="alwaysScroll"