繁体   English   中英

ListView从底部而不是从顶部填充

[英]ListView populates from the bottom instead of from the top

我有一个向上扩展而不是向下扩展的listView。 我在另一个页面上有另一个listView,它运行得很好并从顶部填充自己 - > bot。 为什么我的listView从底部开始而不是从顶部开始?

我的XML`

<ListView
    android:id="@+id/list_view_showRegister"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/showRegister"
    android:layout_alignParentLeft="true"
    android:layout_marginTop="50dp"
    android:clickable="false" >

</ListView>`

您的ListView实际上仍然从顶部向下填充。 只是不是从页面的顶部。

您已设置layout_height="wrap_content"layout_above="@+id/showRegister" 如果高度为wrap_content ,则视图将仅与其内容一样大 然后,由于您使用了layout_above ,它将直接位于另一个视图上方

列表视图不是从底部填充,而是从列表视图的顶部填充 - 但列表视图本身仅从屏幕的中间开始。 列表视图上方的任何内容实际上并不是列表视图的一部分 ,而是空白空间。

解决方案是设置layout_height="match_parent" ,或删除layout_above标记。

我知道这是一个老问题,但我希望这可以帮助其他任何可能通过谷歌找到这个问题的人。

请参阅android:stackFromBottom属性。

看看这些链接。 是否可以从底部填充ListView? 从底部填充。 在Android上添加新项目到列表视图的顶部? 在列表顶部添加新项目。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM