Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scrolling issues with GridView in Android

Tags:

android

I am having weird scrolling issues in my pretty simple GridView. Each item in the Grid is simply an ImageView and a TextView. The activity itself is simply an application selector. It looks like a rough version of the basic App Tray in Android.

The issue is that after spending some times scrolling through my view, it will inevitably allow me to continue scrolling past the top row of icons, to a blank screen, and the scroll bar will disappear, leaving me stuck.

It doesn't happen every time I go to the top of the view, only sometimes, and usually only after some excessive scrolling.

If I happen to notice the problem and catch it before the top row disappears off the bottom of the screen, I can usually scroll back through the view and spot some icons missing. There are empty spaces in the grid, and I can only assume that those icons have been moved to some bizarre position, which is allowing the view to scroll past the top.

This is my first Android app beyond a basic Hello World, so it's likely that I've just screwed up something in my layout files. I also realize that this is probably a pretty confusing description, so I'm hoping someone has experienced this and my search abilities simply were unable to find it.

I can post my layout files or other code if someone thinks that's useful.

Oh, and the program is built against 1.5, but is running on 2.2 (whatever state of 2.2 that was that snuck out last week) on my phone. I don't have enough apps to test this on an emulator, but could probably set something up if someone felt it necessary.

Thanks in advance for any help on the issue.

like image 979
Jared Avatar asked Jun 01 '10 02:06

Jared


3 Answers

I had same problem, but I post to GridView only ImageView's so pengwang's answer didn't help me. I found explanation for this bug https://code.google.com/p/android/issues/detail?id=16218

The problem is that GridView does not currently handle items with differing heights.

My solution is to use exactly specified layout_height same for all GridView's items.

like image 171
Sergei Vasilenko Avatar answered Nov 18 '22 00:11

Sergei Vasilenko


i have solved it: in the link GridView cannot show image you can try

like image 26
pengwang Avatar answered Nov 17 '22 22:11

pengwang


It seems that if you scroll off the bottom of the GridView and back again very fast a couple of times, you eventually will notice that the elements of the view get shifted one place to the "left" from where they originally were. When this happens, you then can scroll all the way off the top of the GridView. When you do reach the top of the list, item 0 is not displayed, having item 1 in its place and nothing but blackness above that row.

Clicking on any item in this situation resets the list and everything is back to normal.

This must be a bug. It's highly reproducible, and I don't think anything I'm doing is causing the mix up. At this point, adding to the list adapter has stopped.

Right now I'm working with Android 2.3.3.

like image 1
Dr. Polar Humenn Avatar answered Nov 17 '22 22:11

Dr. Polar Humenn