android - Image view in grid view is scrolled partially when we do scroll on grid view -
i have gridview 2 columns. users can scroll vertically see gridview items.
the problem when user has finished scrolling, first row not visible. want set top of first visible row top of gridview first row visible.
can me?
can try this. tried listview in project
mgridview.setonscrolllistener(new onscrolllistener() { private int currentfirstvisibleitem; private int currentvisibleitemcount; private int currentscrollstate; public void onscroll(abslistview view, int firstvisibleitem, int visibleitemcount, int totalitemcount) { this.currentfirstvisibleitem = firstvisibleitem; this.currentvisibleitemcount = visibleitemcount; } public void onscrollstatechanged(abslistview view, int scrollstate) { this.currentscrollstate = scrollstate; this.isscrollcompleted(); } private void isscrollcompleted() { if (mgridview.getlastvisibleposition() == mgridview.getadapter().getcount() - 1 && mgridview.getchildat(mgridview.getchildcount() - 1).getbottom() <= mgridview.getheight()) { if (this.currentvisibleitemcount > 0 && this.currentscrollstate == scroll_state_idle) { mgridview.smoothscrolltoposition(-1); } } } } });
Comments
Post a Comment