【发布时间】:2011-05-10 01:27:34
【问题描述】:
我得到所有应用程序的图标,并在 GridView 中显示这些图标。 GridView 可以很好地显示它们,但是当我将 GridView 快速向下滑动时,有时 GridView 缺少两个图标。这种情况不常出现,能否给点建议。
编辑:之前有人问过这个问题,但没有答案。 Scrolling issues with GridView in Android
【问题讨论】:
我得到所有应用程序的图标,并在 GridView 中显示这些图标。 GridView 可以很好地显示它们,但是当我将 GridView 快速向下滑动时,有时 GridView 缺少两个图标。这种情况不常出现,能否给点建议。
编辑:之前有人问过这个问题,但没有答案。 Scrolling issues with GridView in Android
【问题讨论】:
在我的情况下,我已经在使用这些 XML 显示图像和文本的 GridView 适配器中解决了这个问题:
<!-- <LinearLayout android:layout_width="fill_parent" android:layout_height="18dip" /> -->
<LinearLayout
android:id="@+id/iconBackgroundLinear"
android:layout_width="54dip"
android:layout_height="57dip"
android:gravity="center">
<ImageView
android:id="@+id/app_icon"
android:layout_width="45dip"
android:layout_height="45dip"
android:adjustViewBounds="false"
/>
</LinearLayout>
<TextView
android:id="@+id/app_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="2dip"
android:gravity="center_horizontal"
android:lines="2"
/>
</LinearLayout>
关键是 android:lines="2",当我使用 android:maxline="2" 时,可能会出现上述错误。
【讨论】:
我已经解决了这个问题,替换为
<LinearLayout
android:orientation="horizontal"
android:layout_marginTop="@dimen/big_margin"
android:layout_width="match_parent"
android:layout_marginLeft="@dimen/big_margin"
android:layout_height="wrap_content">
到
<LinearLayout
android:orientation="horizontal"
android:layout_marginTop="@dimen/big_margin"
android:layout_width="match_parent"
android:layout_marginLeft="@dimen/big_margin"
android:layout_height="@dimen/workoutlist_itemheight">
但我真的不知道我的问题是如何解决的。
谢谢
【讨论】: