@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { int width = getMeasuredWidth(); int height = getMeasuredHeight(); layoutSubView(mSearch, mActionGap, 0); layoutSubView(mShare, 2 * mActionGap + mSearch.getMeasuredWidth(), 0); layoutSubView(mTrans, 3 * mActionGap + mTrans.getMeasuredWidth() + mShare.getMeasuredWidth(), 0); // layoutSubView(mSelectAll, 2 * mActionGap + mSearch.getMeasuredWidth() , 0); // layoutSubView(mSelectOther, 3 * mActionGap + mTrans.getMeasuredWidth()+ mShare.getMeasuredWidth() , 0); // // layoutSubView(mDrag, width - mActionGap * 2 - mShare.getMeasuredWidth() - mCopy.getMeasuredWidth(), 0); layoutSubView(mCopy, width - mActionGap - mCopy.getMeasuredWidth(), 0); layoutSubView(mClose, ((width - (this.mActionGap * 2)) - this.mCopy.getMeasuredWidth()) - this.mClose.getMeasuredHeight(), 0); Rect oldBounds = mBorder.getBounds(); Rect newBounds = new Rect(0, mSearch.getMeasuredHeight() / 2, width, height); if (!stickHeader && !oldBounds.equals(newBounds)) { ObjectAnimator.ofObject(new BoundWrapper(oldBounds), "bound", new RectEvaluator(), oldBounds, newBounds).setDuration(200).start(); } }
public void startRectAnimation(View v) { Rect local = new Rect(); mShowAnimIV.getLocalVisibleRect(local); Rect from = new Rect(local); Rect to = new Rect(local); from.right = from.left + local.width()/4; from.bottom = from.top + local.height()/2; to.left = to.right - local.width()/2; to.top = to.bottom - local.height()/4; if (Build.VERSION.SDK_INT >= 18) { ObjectAnimator objectAnimator = ObjectAnimator.ofObject(mShowAnimIV, "clipBounds", new RectEvaluator(), from, to); objectAnimator.setDuration(C.Int.ANIM_DURATION * 4); objectAnimator.start(); } }
@SuppressLint("NewApi") public void startRectAnimation(View view) { View someImage = findViewById(R.id.some_image); Rect local = new Rect(); someImage.getLocalVisibleRect(local); Rect from = new Rect(local); Rect to = new Rect(local); from.right = from.left + local.width()/4; from.bottom = from.top + local.height()/2; to.left = to.right - local.width()/2; to.top = to.bottom - local.height()/4; if (android.os.Build.VERSION.SDK_INT >= 18) { ObjectAnimator anim = ObjectAnimator.ofObject(someImage, "clipBounds", new RectEvaluator(), from, to); anim.setDuration(2000); anim.start(); } }