GridView cannot show image

2020-03-07 08:51发布

问题:

I get all application's icons, and show the icons in GridView. The GridView shows them very well, but when I glides the GridView very fast to downward, sometimes lack of two icons at GridView. This kind of situation not often appears, can you give me some advice.

EDIT : this question have been asked before, but no answers. Scrolling issues with GridView in Android

回答1:

I have solved it, in my situation, in the adapter of GridView that I used these XML to show image and text:

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

The key is android:lines="2", when I am using android:maxline="2" , it may show above mistake.



回答2:

i have solved this problem replaced by

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

to

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

but really i don't know how did my issue solved.

thanks