2011-05-10 86 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"> 

但我真的不知道爲什麼我的問題是如何解決的。

謝謝