コード例 #1
0
 @Override
 public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   if (mTarget == null) {
     ensureTarget();
   }
   if (mTarget == null) {
     return;
   }
   mTarget.measure(
       MeasureSpec.makeMeasureSpec(
           getMeasuredWidth() - getPaddingLeft() - getPaddingRight(), MeasureSpec.EXACTLY),
       MeasureSpec.makeMeasureSpec(
           getMeasuredHeight() - getPaddingTop() - getPaddingBottom(), MeasureSpec.EXACTLY));
   mCircleView.measure(
       MeasureSpec.makeMeasureSpec(mCircleWidth, MeasureSpec.EXACTLY),
       MeasureSpec.makeMeasureSpec(mCircleHeight, MeasureSpec.EXACTLY));
   if (!mUsingCustomStart && !mOriginalOffsetCalculated) {
     mOriginalOffsetCalculated = true;
     mCurrentTargetOffsetTop = mOriginalOffsetTop = -mCircleView.getMeasuredHeight();
   }
   mCircleViewIndex = -1;
   // Get the index of the circleview.
   for (int index = 0; index < getChildCount(); index++) {
     if (getChildAt(index) == mCircleView) {
       mCircleViewIndex = index;
       break;
     }
   }
 }
コード例 #2
0
 @Override
 protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
   final int width = getMeasuredWidth();
   final int height = getMeasuredHeight();
   if (getChildCount() == 0) {
     return;
   }
   if (mTarget == null) {
     ensureTarget();
   }
   if (mTarget == null) {
     return;
   }
   final View child = mTarget;
   final int childLeft = getPaddingLeft();
   final int childTop = getPaddingTop();
   final int childWidth = width - getPaddingLeft() - getPaddingRight();
   final int childHeight = height - getPaddingTop() - getPaddingBottom();
   child.layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight);
   int circleWidth = mCircleView.getMeasuredWidth();
   int circleHeight = mCircleView.getMeasuredHeight();
   mCircleView.layout(
       (width / 2 - circleWidth / 2),
       mCurrentTargetOffsetTop,
       (width / 2 + circleWidth / 2),
       mCurrentTargetOffsetTop + circleHeight);
 }
コード例 #3
0
 /**
  * Get the diameter of the progress circle that is displayed as part of the swipe to refresh
  * layout. This is not valid until a measure pass has completed.
  *
  * @return Diameter in pixels of the progress circle view.
  */
 public int getProgressCircleDiameter() {
   return mCircleView != null ? mCircleView.getMeasuredHeight() : 0;
 }