ListView的背景滚动数据 [英] ListView background scroll with data

查看:94
本文介绍了ListView的背景滚动数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能使一个背景舒展在整个ListView的,而不是仅仅停留在一个固定的位置?

Is it possible to make a background stretch over the whole ListView, instead of just staying on a fixed position?

做网站时,你可以使背景附件固定的背景滚动时,我试图存档该相反留在同一个地方,使背景遵循的数据,当你向下滚动我记得在CSS。是否有这样的事情的ListView?

I remember in CSS when making websites you could make the background-attachment fixed for a background to stay the same place when scrolling, I am trying to archive the opposite of this, making the background follow the data when you scroll down. Is there such a thing for ListView?

推荐答案

使用一只股票的ListView做你想要什么是不可能的。

Using a stock ListView to do what you want would not be possible.

ListView控件只是为了节省视图创建/管理/等一次显示几排。可能陷入系统瘫痪。其结果是,在ListView甚至不知道其自身的总高度 - 它不呈现一个行,直到该行是可见的,并且行可以在高度发生变化。如果它甚至不知道自己的身高,怎么可能有一个背景,跨越了它的全部?

ListView only displays a few rows at a time in order to save on View creation/management/etc. that could bog the system down. As a result, the ListView doesn't even know the total height of itself - it doesn't render a row until that row is visible, and rows can vary in height. If it doesn't even know its own height, how could it have a background that spans the entirety of it?

这是说,您使用的是滚动型的的想法是的可能。然而,你将被失去了对ListView的优化 - 如果你只有几行,那么这是不是一个大问题;但如果你在谈论数十行(或以上),那么你的应用程序可能会严重突突。还有,你没有得到ListView的框架,它是着眼于使一个简单的基于行的用户界面。

That said, your idea of using a ScrollView would be possible. However, you would then be losing out on ListView's optimization - if you only had few rows, then this isn't a big deal; but if you're talking about dozens of rows (or more), then your app may seriously chug. Also, you don't get ListView's framework, which is geared towards making an easier row-based UI.

这将有可能编写自己的ListView子类(或自定义的ListView),可以计算其总高度(只要你知道每一行是一个固定的高度),然后相应地绘制背景。这可能是我会怎么做,如果我的需要的做你的描述,并有太多的行只是塞给她一个滚动型舒适。

It would be possible to write your own ListView subclass (or custom ListView) that can calculate its total height (so long as you know that each row is of a fixed height), then draw the background accordingly. That is probably what I'd do if I was required to do what you describe and had too many rows to just stuff into a ScrollView comfortably.

这篇关于ListView的背景滚动数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆