2011-05-10 88 views
1

我得到的所有应用程序的图标,并显示在GridView中的图标。 GridView可以很好地显示它们,但是当我将GridView非常快速地向下滑动时,有时在GridView中缺少两个图标。这种情况并不常出现,你能否给我一些建议。GridView控件不能显示图像

编辑:这个问题已经被问过,但没有答案。 Scrolling issues with GridView in Android

回答

20

我已经解决了这个问题,在我的情况,因为我用这些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> 

的关键是机器人:行=“2”,当我使用机器人:MAXLINE =“2”,它可能会显示上述错误。

+0

我认为你只是幸运。我有同样的问题,没有任何文本,有一个ViewSwitcher与简单的LinearLayout元素和形状背景。似乎是一个奇怪的Android错误... – 2012-04-10 04:49:37

+1

虽然这并真正解决了我的问题,但它暗示了他们是一些更根本性的错误GridView控件。也许它不喜欢变量高度条目? – 2012-07-02 16:30:18

+0

我想只保留了android:线相同的价值,也许可以重温你的问题 – pengwang 2012-07-03 01:11:16

0

我已经解决了这个问题,通过

<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"> 

但我真的不知道为什么我的问题是如何解决的。

谢谢