is View Scroll To Top - Android User Interface

Android examples for User Interface:ScrollView

Description

is View Scroll To Top

Demo Code


import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.ScrollView;

public class Main{
    public static boolean isScrollToTop(View view) {
        if (view instanceof ListView) {
            ListView listView = (ListView) view;
            int first = listView.getFirstVisiblePosition();
            return first == 0;
        } else if (view instanceof RecyclerView) {
            RecyclerView recyclerView = (RecyclerView) view;
            return !recyclerView.canScrollVertically(-1);
        } else if (view instanceof ScrollView) {
            ScrollView scrollView = (ScrollView) view;
            return scrollView.getScrollY() == 0;
        } else if (view instanceof DSRefView) {
            DSRefView dsRefView = (DSRefView) view;
            return dsRefView.isReleaseTouch();
        }/*  w  ww  .  j  a va 2s  . c o m*/
        return true;
    }
}

Related Tutorials