我需要找出列表中一个元素的像素位置,这个列表是使用 ListView
显示的。似乎我应该得到一个 TextView 的,然后使用 getTop()
,但我不知道如何得到一个 ListView
的子视图。
更新: 对于 ListView
,ViewGroup
的子元素与列表中的项目不对应1:1。相反,ViewGroup
的子元素只对应于那些现在可见的视图。因此,getChildAt()
操作的索引位于 ViewGroup
的内部,与 ListView
使用的列表中的位置没有必然的关系。