pengwang pengwang - 5 months ago 29
Android Question

GridView cannot show image

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

Answer

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.

Comments