@Override
          public void onClick(View v) {
            if (startButton.getVisibility() == View.VISIBLE) {
              startButton.setVisibility(View.INVISIBLE);
            }

            if (upAnimation.isStarted()) {
              upAnimation.cancel();
            }

            if (startPosition == 0) {
              startPosition = bird.getTop();
            }

            isUpAnimationCancelled = false;
            isDownEndByClick = true;
            // bird.layout(bird.getLeft(), 228, bird.getRight(), 228 + bird.getMeasuredHeight());
            bird.layout(
                bird.getLeft(),
                (int) bird.getY(),
                bird.getRight(),
                (int) bird.getY() + bird.getMeasuredHeight());
            bird.setTranslationY(0);
            upAnimation.start();
          }
Example #2
0
  @Override
  public void onGlobalLayout() {
    ImageView imageView = getImageView();
    if (null != imageView) {
      if (mZoomEnabled) {
        final int top = imageView.getTop();
        final int right = imageView.getRight();
        final int bottom = imageView.getBottom();
        final int left = imageView.getLeft();

        /**
         * We need to check whether the ImageView's bounds have changed. This would be easier if we
         * targeted API 11+ as we could just use View.OnLayoutChangeListener. Instead we have to
         * replicate the work, keeping track of the ImageView's bounds and then checking if the
         * values change.
         */
        if (top != mIvTop || bottom != mIvBottom || left != mIvLeft || right != mIvRight) {
          // Update our base matrix, as the bounds have changed
          updateBaseMatrix(imageView.getDrawable());

          // Update values as something has changed
          mIvTop = top;
          mIvRight = right;
          mIvBottom = bottom;
          mIvLeft = left;
        }
      } else {
        updateBaseMatrix(imageView.getDrawable());
      }
    }
  }
Example #3
0
 public void BallStart() {
   int height = image.getBottom() - image.getTop();
   int width = image.getRight() - image.getLeft();
   Log.v("hehe", "" + arrayMap.getStart());
   image.layout(
       arrayMap.getStart().x - width / 2,
       arrayMap.getStart().y - height / 2,
       arrayMap.getStart().x - width / 2 + width,
       arrayMap.getStart().y - height / 2 + height);
 }
 void getImageCordinates() {
   final RelativeLayout parent = (RelativeLayout) findViewById(R.id.parent);
   for (int i = 1; i < 10; i++) {
     try {
       String action1 = X + i;
       final ImageView view1 =
           (ImageView) parent.findViewById((R.id.class.getField(action1).getInt(null)));
       coordinatesMap.put(i, new PointF(view1.getLeft(), view1.getTop()));
       System.out.println(
           "Coordinate at posn="
               + i
               + " is "
               + (view1.getLeft() - view1.getWidth() / 2)
               + ","
               + (view1.getTop() - view1.getHeight() / 2));
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }
 private void setViewForMiddle() {
   ImageView v = (ImageView) mMiddle.findViewById(R.id.long_bar);
   v.setImageResource(mid_image_selected_list[mSelectedPosition % mid_image_selected_list.length]);
   int t = v.getTop();
   int height = v.getHeight();
   int l = mSelectedPosition % ITEM_NUM * 240;
   int width = v.getWidth();
   RelativeLayout.LayoutParams lp = (LayoutParams) v.getLayoutParams();
   lp.leftMargin = mSelectedPosition % ITEM_NUM * 240;
   v.setLayoutParams(lp);
 }
 @Override
 public void onAnimationEnd(Animator animation) {
   // TODO Auto-generated method stub
   Log.v(
       "Debug",
       "Animation End: "
           + bird.getY()
           + ".."
           + bird.getTop()
           + ".."
           + bird.getTranslationY());
   if (!isUpAnimationCancelled) {
     // start to drop
     // downAnimation.setFloatValues(deltaY);
     bird.layout(
         bird.getLeft(),
         (int) bird.getY(),
         bird.getRight(),
         (int) bird.getY() + bird.getMeasuredHeight());
     bird.setTranslationY(0);
     downAnimation.setFloatValues(startPosition - bird.getTop());
     downAnimation.start();
   }
 }
Example #7
0
 public static void blur(Context context, Bitmap bkg, ImageView view) {
   float radius = 2;
   float scaleFactor = 8;
   Bitmap overlay =
       Bitmap.createBitmap(
           (int) (view.getMeasuredWidth() / scaleFactor),
           (int) (view.getMeasuredHeight() / scaleFactor),
           Bitmap.Config.ARGB_8888);
   Canvas canvas = new Canvas(overlay);
   canvas.translate(-view.getLeft() / scaleFactor, -view.getTop() / scaleFactor);
   canvas.scale(1 / scaleFactor, 1 / scaleFactor);
   Paint paint = new Paint();
   paint.setFlags(Paint.FILTER_BITMAP_FLAG);
   canvas.drawBitmap(bkg, 0, 0, paint);
   overlay = doBlur(overlay, (int) radius, true);
   view.setImageDrawable(new BitmapDrawable(context.getResources(), overlay));
 }
Example #8
0
 /**
  * @author alan.xie
  * @date 2014-12-1 上午11:59:38 @Description: 图片随手势移�?
  * @param @param canvas
  * @return void
  */
 private void invalidateDragImg(Canvas canvas) {
   int drawX = locationX - heartView.getWidth() / 2;
   int drawY = heartView.getTop();
   Log.i(TAG, "重绘=" + drawX);
   if (!flag) {
     heartView.setVisibility(View.VISIBLE);
     return;
   } else {
     if (locationX < linearLayoutL.getWidth() - 10) { // 滑动到最左边,heartView消失
       linearLayoutL.setBackgroundResource(R.drawable.left_bg_select);
       return;
     }
     if (locationX > (getScreenWidth() - linearLayoutR.getWidth() - 20)) { // 滑到�?���?heartView 消失
       linearLayoutR.setBackgroundResource(R.drawable.left_bg_select);
       return;
     }
     heartView.setVisibility(View.GONE);
     if (drawX > linearLayoutL.getWidth() / 2) {
       canvas.drawBitmap(dragBitmap, drawX, drawY, null);
     }
   }
 }
    void hide() {
      boolean horiz = alignment == ALIGN_LEFT || alignment == ALIGN_RIGHT;
      int dx =
          horiz
              ? (alignment == ALIGN_LEFT
                  ? alignment_value - tab.getRight()
                  : alignment_value - tab.getLeft())
              : 0;
      int dy =
          horiz
              ? 0
              : (alignment == ALIGN_TOP
                  ? alignment_value - tab.getBottom()
                  : alignment_value - tab.getTop());

      Animation trans = new TranslateAnimation(0, dx, 0, dy);
      trans.setDuration(ANIM_DURATION);
      trans.setFillAfter(true);
      tab.startAnimation(trans);
      text.startAnimation(trans);
      target.setVisibility(View.INVISIBLE);
    }
 void reset(boolean animate) {
   setState(STATE_NORMAL);
   text.setVisibility(View.VISIBLE);
   text.setTextAppearance(text.getContext(), R.style.TextAppearance_SlidingTabNormal);
   tab.setVisibility(View.VISIBLE);
   target.setVisibility(View.INVISIBLE);
   final boolean horiz = alignment == ALIGN_LEFT || alignment == ALIGN_RIGHT;
   int dx =
       horiz
           ? (alignment == ALIGN_LEFT
               ? alignment_value - tab.getLeft()
               : alignment_value - tab.getRight())
           : 0;
   int dy =
       horiz
           ? 0
           : (alignment == ALIGN_TOP
               ? alignment_value - tab.getTop()
               : alignment_value - tab.getBottom());
   if (animate) {
     TranslateAnimation trans = new TranslateAnimation(0, dx, 0, dy);
     trans.setDuration(ANIM_DURATION);
     trans.setFillAfter(false);
     text.startAnimation(trans);
     tab.startAnimation(trans);
   } else {
     if (horiz) {
       text.offsetLeftAndRight(dx);
       tab.offsetLeftAndRight(dx);
     } else {
       text.offsetTopAndBottom(dy);
       tab.offsetTopAndBottom(dy);
     }
     text.clearAnimation();
     tab.clearAnimation();
     target.clearAnimation();
   }
 }
Example #11
0
  /** 指定光标相对位置 */
  private void setBorderParams(final View item) {
    cursor.clearAnimation();
    cursor.setVisibility(View.VISIBLE);
    final RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) item.getLayoutParams();
    final int l = params.leftMargin + paddingLeft - boarderLeft;
    final int t = params.topMargin + paddingTop - boarderTop;
    final int r = l + itemWidth + boarderRight;
    final int b = t + itemHeight + boarderBottom;
    // 判断动画类型
    switch (animationType) {
      case ANIM_DEFAULT:
        cursor.layout(l, t, r, b);
        item.bringToFront();
        cursor.bringToFront();
        if (scalable) {
          scaleToLarge(item);
        }
        break;
      case ANIM_TRASLATE:
        ValueAnimator transAnimatorX = ObjectAnimator.ofFloat(cursor, "x", cursor.getLeft(), l);
        ValueAnimator transAnimatorY = ObjectAnimator.ofFloat(cursor, "y", cursor.getTop(), t);
        cursor.layout(l, t, r, b);
        item.bringToFront();
        cursor.bringToFront();
        if (scalable) {
          scaleToLarge(item);
        }
        if (focusIsOut) {
          return;
        }

        animatorSet = new AnimatorSet();
        animatorSet.play(transAnimatorY).with(transAnimatorX);
        animatorSet.setDuration(durationTraslate);
        animatorSet.setInterpolator(new DecelerateInterpolator(1));
        //			animatorSet.addListener(new AnimatorListener() {
        //
        //				@Override
        //				public void onAnimationStart(Animator arg0) {
        //				}
        //
        //				@Override
        //				public void onAnimationRepeat(Animator arg0) {
        //				}
        //
        //				@Override
        //				public void onAnimationEnd(Animator arg0) {
        //					cursor.layout(l, t, r, b);
        //					item.bringToFront();
        //					cursor.bringToFront();
        //					if (scalable) {
        //						scaleToLarge(item);
        //					}
        //				}
        //
        //				@Override
        //				public void onAnimationCancel(Animator arg0) {
        //				}
        //			});
        animatorSet.start();

        break;
    }
  }
	public void setPageControlPosition(
			int offsetX )
	{
		pageControl.layout( offsetX / 3 , pageControl.getTop() , pageControl.getRight() , pageControl.getBottom() );
		;
	}