public boolean canChildScrollDown() {
   if (android.os.Build.VERSION.SDK_INT < 14) {
     if (mTarget instanceof AbsListView) {
       final AbsListView absListView = (AbsListView) mTarget;
       View lastChild = absListView.getChildAt(absListView.getChildCount() - 1);
       if (lastChild != null) {
         return (absListView.getLastVisiblePosition() == (absListView.getCount() - 1))
             && lastChild.getBottom() > absListView.getPaddingBottom();
       } else {
         return false;
       }
     } else {
       return mTarget.getHeight() - mTarget.getScrollY() > 0;
     }
   } else {
     return ViewCompat.canScrollVertically(mTarget, 1);
   }
 }
예제 #2
0
  /**
   * get AbsListView height according to every children
   *
   * @param view
   * @return
   */
  public static int getAbsListViewHeightBasedOnChildren(AbsListView view) {
    ListAdapter adapter;
    if (view == null || (adapter = view.getAdapter()) == null) {
      return 0;
    }

    int height = 0;
    for (int i = 0; i < adapter.getCount(); i++) {
      View item = adapter.getView(i, null, view);
      if (item instanceof ViewGroup) {
        item.setLayoutParams(
            new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
      }
      item.measure(0, 0);
      height += item.getMeasuredHeight();
    }
    height += view.getPaddingTop() + view.getPaddingBottom();
    return height;
  }