【问题标题】:Android listview shows elements at the bottom when there is few elements?当元素很少时,Android listview 在底部显示元素?
【发布时间】:2011-08-25 23:48:59
【问题描述】:

当元素的大小很少时,例如 Listview 中的 1,2 或 3 它在底部显示元素。即使很少,我怎样才能让它在顶部显示元素?这是screenshot

这是我的 xml 代码:

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:padding="4px" 
        android:paddingBottom="4px"
        android:background="@drawable/fbbar"
        android:layout_height="50dip">
    <EditText android:id="@+id/searchText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1" 
        android:layout_gravity="bottom"
        android:hint="type to search..." 
        android:drawableRight="@drawable/ic_search_text"/>
    <Button android:id="@+id/btn_contacts_refresh"
        android:layout_width="0px"
        android:layout_height="0px" 
        android:drawableTop="@drawable/refresh"/>
    </LinearLayout>

    <ListView android:id="@+id/contactsList"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:transcriptMode="alwaysScroll" 
        android:background="#fff" 
        android:cacheColorHint="#00000000"
        android:dividerHeight="1px" android:divider="#777a"/>

    <LinearLayout 
        android:layout_height="2dip" 
        android:layout_width="match_parent" 
        android:orientation="horizontal" 
        android:background="@drawable/fbbar"> 
    </LinearLayout>
</LinearLayout>

【问题讨论】:

  • 这太奇怪了。我不知道,这一切看起来都很好。试试ListViewandroid:layout_gravity="top"。我不知道这是否会有所帮助,但谁知道呢?

标签: android listview


【解决方案1】:

我认为你的问题在这里 android:transcriptMode="alwaysScroll"

【讨论】:

  • 其实我发现这个bug是在java端抱歉
  • 你能解释一下错误吗?我很感兴趣,因为我遇到了同样的情况。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-11-01
  • 1970-01-01
相关资源
最近更新 更多