Skip to content

Instantly share code, notes, and snippets.

@ixiyang
Created August 14, 2014 06:53
Show Gist options
  • Select an option

  • Save ixiyang/b1597ec1edd9cc541e40 to your computer and use it in GitHub Desktop.

Select an option

Save ixiyang/b1597ec1edd9cc541e40 to your computer and use it in GitHub Desktop.

Revisions

  1. ixiyang created this gist Aug 14, 2014.
    18 changes: 18 additions & 0 deletions canChildScrollUp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    /**
    * @return Whether it is possible for the child view of this layout to
    * scroll up. Override this if the child view is a custom view.
    */
    public boolean canChildScrollUp() {
    if (android.os.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 {
    return mTarget.getScrollY() > 0;
    }
    } else {
    return ViewCompat.canScrollVertically(mTarget, -1);
    }
    }