【问题标题】:android listview doesn't stick on the top of the layoutandroid listview 不粘在布局的顶部
【发布时间】:2011-11-01 19:00:23
【问题描述】:

我有这个 xml 文件。该列表包含 2 个项目。当我在 SDK 模拟器或平板电脑上测试应用程序时,它显示为有意的。但是,当我在装有 Android v2.2.1 的三星 GT-S5570 上下载该应用程序时,用户可以从顶部拖动列表并将其移至屏幕底部。有什么办法可以防止这种情况发生吗?

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android">
    <ListView 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:paddingTop="20dip"
        android:id="@android:id/list"
        android:cacheColorHint="@android:color/transparent"
        android:textAppearance="?android:attr/textAppearance"/>
</RelativeLayout>

【问题讨论】:

  • 这可能是操作系统的默认行为。
  • 这就是我的怀疑,我认为唯一的解决方案是使用 Paresh 链接建议的 ScrollView。

标签: android listview layout


【解决方案1】:

如果您只想显示有限数量的项目,请将这些项目放在 ScrollView 中,而不是使用 ListView。

ListView 旨在通过滚动视图显示无限数量的项目以滚动其他项目。

这个答案信息量更大,更有帮助:how can i automatically size listview so it doesn't scroll

【讨论】:

  • 我很明白。但是我必须补充一点,我已经看到手机浏览器的下载管理器也发生了同样的事情,所以我无法确定这是 android 开发人员遵循的糟糕设计,还是只是在其他方面修复了一些行为设备。
猜你喜欢
  • 1970-01-01
  • 2014-01-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-30
  • 2012-12-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多