can Child View Scroll Up - Android User Interface

Android examples for User Interface:ScrollView

Description

can Child View Scroll Up

Demo Code


import android.os.Build;
import android.support.v4.view.ViewCompat;
import android.view.View;
import android.widget.AbsListView;

public class Main {
  private static boolean canChildScrollUp(View mTarget) {
    if (Build.VERSION.SDK_INT < 14) {
      if (mTarget instanceof AbsListView) {
        final AbsListView absListView = (AbsListView) mTarget;
        return absListView.getChildCount() > 0
            && (absListView.getFirstVisiblePosition() > 0 || absListView
                .getChildAt(0).getTop() < absListView.getPaddingTop());
      } else {/*from www  . j  ava2  s.  c  om*/
        return mTarget.getScrollY() > 0;
      }
    } else {
      return ViewCompat.canScrollVertically(mTarget, -1);
    }
  }
}

Related Tutorials