get GridView Up Scroll - Android User Interface

Android examples for User Interface:GridView

Description

get GridView Up Scroll

Demo Code


//package com.java2s;
import android.widget.GridView;

public class Main {
    public static void getGridViewUpScroll(GridView gv) {
        int first = gv.getFirstVisiblePosition();
        int last = gv.getLastVisiblePosition();

        int targetPosition = first
                - (last - first + 1 - gv.getNumColumns());

        gv.smoothScrollToPositionFromTop(targetPosition, 0);
    }/*from w  w  w.j  a v a2s  .  c  o m*/
}

Related Tutorials