GridView cannot show image
Asked Answered
E

2

1

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

Eclat answered 10/5, 2011 at 1:27 Comment(0)
E
23

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.

Eclat answered 11/5, 2011 at 0:59 Comment(6)
I think that you were just lucky. I have the same issue, without any text, having a ViewSwitcher with plain LinearLayout elements and Shape backgrounds. Seems like a wierd Android bug...Placida
While this does actually solve the problem for me, it hints at their being something more fundamentally wrong with GridView. Perhaps it doesn't like variable height entries?Layer
i think only keep the android:lines value same,maybe can relive your questionEclat
It does the trick for me too. I too had a similarly structured gridview with an ImageView and TextView and the text was totally random in length. Thanks for the answer.Catlin
Didn't solve shit thus solution is as bad as the internet can inform. Don't listen to this shit.Doctrine
This is by far the best solution i've got and it worked like a charm. Also needs to set fixed height and width to the parent layout of gridView item.Chilon
F
0

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

Foucquet answered 9/6, 2016 at 12:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.