List of usage examples for android.view View setPivotY
public void setPivotY(float pivotY)
From source file:com.gabm.fancyplaces.ui.MainWindow.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { menu.clear();/*from w w w . j a v a 2 s .co m*/ getMenuInflater().inflate(curState.curMenu, menu); Toolbar toolbar = (Toolbar) findViewById(R.id.main_window_toolbar); if (curState.curMenu == R.menu.menu_main_window_multi_select) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); toolbar.setTitle(getString(R.string.main_multi_selection_title)); toolbar.setBackgroundColor(getResources().getColor(R.color.ColorPrimaryDark)); int noOfChild = toolbar.getChildCount(); View view; // animate toolbar elements for (int i = 1; i < noOfChild; i++) { view = toolbar.getChildAt(i); view.setAlpha(0); view.setScaleY(0); view.setPivotY((float) 0.5 * view.getHeight()); view.animate().setDuration(200).scaleY(1).alpha(1); } } else if (curState.curMenu == R.menu.menu_main_window) { getSupportActionBar().setDisplayHomeAsUpEnabled(false); setDefaultTitle(); toolbar.setBackgroundColor(getResources().getColor(R.color.ColorPrimary)); } return super.onPrepareOptionsMenu(menu); }
From source file:android.improving.utils.views.cardsview.StackPageTransformer.java
@Override public void transformPage(View view, float position) { int dimen = 0; switch (mOrientation) { case VERTICAL: dimen = view.getHeight();// w w w .j a v a2 s.c o m break; case HORIZONTAL: dimen = view.getWidth(); break; } if (!mInitialValuesCalculated) { mInitialValuesCalculated = true; calculateInitialValues(dimen); } switch (mOrientation) { case VERTICAL: view.setRotationX(0); view.setPivotY(dimen / 2f); view.setPivotX(view.getWidth() / 2f); break; case HORIZONTAL: view.setRotationY(0); view.setPivotX(dimen / 2f); view.setPivotY(view.getHeight() / 2f); break; } if (position < -mNumberOfStacked - 1) { view.setAlpha(0f); } else if (position <= 0) { float scale = mZeroPositionScale + (position * mStackedScaleFactor); float baseTranslation = (-position * dimen); float shiftTranslation = calculateShiftForScale(position, scale, dimen); view.setScaleX(scale); view.setScaleY(scale); view.setAlpha(1.0f + (position * mAlphaFactor)); switch (mOrientation) { case VERTICAL: view.setTranslationY(baseTranslation + shiftTranslation); break; case HORIZONTAL: view.setTranslationX(baseTranslation + shiftTranslation); break; } } else if (position <= 1) { float scale = mZeroPositionScale + (position * mStackedScaleFactor); view.setScaleX(scale); view.setScaleY(scale); view.setAlpha(1.0f + (position * mAlphaFactor)); view.setTranslationY(position); } else if (position > 1) { view.setAlpha(0f); } }
From source file:arun.com.chromer.browsing.article.view.ElasticDragDismissFrameLayout.java
private void dragScale(int scroll) { if (scroll == 0) return;//from w ww . j av a2 s . c om totalDrag += scroll; View child = getChildAt(0); // track the direction & set the pivot point for scaling // don't double track i.e. if play dragging down and then reverse, keep tracking as // dragging down until they reach the 'natural' position if (scroll < 0 && !draggingUp && !draggingDown) { draggingDown = true; if (shouldScale) child.setPivotY(getHeight()); } else if (scroll > 0 && !draggingDown && !draggingUp) { draggingUp = true; if (shouldScale) child.setPivotY(0f); } // how far have we dragged relative to the distance to perform a dismiss // (01 where 1 = dismiss distance). Decreasing logarithmically as we approach the limit float dragFraction = (float) Math.log10(1 + (Math.abs(totalDrag) / dragDismissDistance)); // calculate the desired translation given the drag fraction float dragTo = dragFraction * dragDismissDistance * dragElasticity; if (draggingUp) { // as we use the absolute magnitude when calculating the drag fraction, need to // re-apply the drag direction dragTo *= -1; } child.setTranslationY(dragTo); if (draggingBackground == null) { draggingBackground = new RectF(); draggingBackground.left = 0; draggingBackground.right = getWidth(); } if (shouldScale) { final float scale = 1 - ((1 - dragDismissScale) * dragFraction); child.setScaleX(scale); child.setScaleY(scale); } // if we've reversed direction and gone past the settle point then clear the flags to // allow the list to get the scroll events & reset any transforms if ((draggingDown && totalDrag >= 0) || (draggingUp && totalDrag <= 0)) { totalDrag = dragTo = dragFraction = 0; draggingDown = draggingUp = false; child.setTranslationY(0f); child.setScaleX(1f); child.setScaleY(1f); } // draw the background above or below the view where it has scrolled at if (draggingUp) { draggingBackground.bottom = getHeight(); draggingBackground.top = getHeight() + dragTo; invalidate(); } else if (draggingDown) { draggingBackground.top = 0; draggingBackground.bottom = dragTo; invalidate(); } dispatchDragCallback(dragFraction, dragTo, Math.min(1f, Math.abs(totalDrag) / dragDismissDistance), totalDrag); }
From source file:com.taobao.weex.ui.animation.WXAnimationModule.java
private static @Nullable ObjectAnimator createAnimator(@NonNull WXAnimationBean animation, final View target, final int viewPortWidth) { if (target == null) { return null; }//from w w w. j a v a2 s .c o m WXAnimationBean.Style style = animation.styles; if (style != null) { ObjectAnimator animator; List<PropertyValuesHolder> holders = style.getHolders(); if (!TextUtils.isEmpty(style.backgroundColor)) { BorderDrawable borderDrawable; if ((borderDrawable = WXViewUtils.getBorderDrawable(target)) != null) { holders.add(PropertyValuesHolder.ofObject(WXAnimationBean.Style.BACKGROUND_COLOR, new ArgbEvaluator(), borderDrawable.getColor(), WXResourceUtils.getColor(style.backgroundColor))); } else if (target.getBackground() instanceof ColorDrawable) { holders.add(PropertyValuesHolder.ofObject(WXAnimationBean.Style.BACKGROUND_COLOR, new ArgbEvaluator(), ((ColorDrawable) target.getBackground()).getColor(), WXResourceUtils.getColor(style.backgroundColor))); } } if (style.getPivot() != null) { Pair<Float, Float> pair = style.getPivot(); target.setPivotX(pair.first); target.setPivotY(pair.second); } animator = ObjectAnimator.ofPropertyValuesHolder(target, holders.toArray(new PropertyValuesHolder[holders.size()])); animator.setStartDelay(animation.delay); if (target.getLayoutParams() != null && (!TextUtils.isEmpty(style.width) || !TextUtils.isEmpty(style.height))) { DimensionUpdateListener listener = new DimensionUpdateListener(target); ViewGroup.LayoutParams layoutParams = target.getLayoutParams(); if (!TextUtils.isEmpty(style.width)) { listener.setWidth(layoutParams.width, (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.width), viewPortWidth)); } if (!TextUtils.isEmpty(style.height)) { listener.setHeight(layoutParams.height, (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.height), viewPortWidth)); } animator.addUpdateListener(listener); } return animator; } else { return null; } }
From source file:cn.edu.nuc.seeworld.view.flippablestackview.StackPageTransformer.java
@Override public void transformPage(View view, float position) { int dimen = 0; switch (mOrientation) { case VERTICAL: dimen = view.getHeight();/* w ww . j av a2s. com*/ break; case HORIZONTAL: dimen = view.getWidth(); break; } if (!mInitialValuesCalculated) { mInitialValuesCalculated = true; calculateInitialValues(dimen); } switch (mOrientation) { case VERTICAL: view.setRotationX(0); view.setPivotY(dimen / 2f); view.setPivotX(view.getWidth() / 2f); break; case HORIZONTAL: view.setRotationY(0); view.setPivotX(dimen / 2f); view.setPivotY(view.getHeight() / 2f); break; } if (position < -mNumberOfStacked - 1) { view.setAlpha(0f); } else if (position <= 0) { float scale = mZeroPositionScale + (position * mStackedScaleFactor); float baseTranslation = (-position * dimen); float shiftTranslation = calculateShiftForScale(position, scale, dimen); view.setScaleX(scale); view.setScaleY(scale); view.setAlpha(1.0f + (position * mAlphaFactor)); switch (mOrientation) { case VERTICAL: view.setTranslationY(baseTranslation + shiftTranslation); break; case HORIZONTAL: view.setTranslationX(baseTranslation + shiftTranslation); break; } } else if (position <= 1) { float baseTranslation = position * dimen; float scale = mZeroPositionScale - mValueInterpolator.map(mScaleInterpolator.getInterpolation(position)); scale = (scale < 0) ? 0f : scale; float shiftTranslation = (1.0f - position) * mOverlap; float rotation = -mRotationInterpolator.getInterpolation(position) * 90; rotation = (rotation < -90) ? -90 : rotation; float alpha = 1.0f - position; alpha = (alpha < 0) ? 0f : alpha; view.setAlpha(alpha); switch (mOrientation) { case VERTICAL: view.setPivotY(dimen); view.setRotationX(rotation); view.setScaleX(mZeroPositionScale); view.setScaleY(scale); view.setTranslationY(-baseTranslation - mBelowStackSpace - shiftTranslation); break; case HORIZONTAL: view.setPivotX(dimen); view.setRotationY(-rotation); view.setScaleY(mZeroPositionScale); view.setScaleX(scale); view.setTranslationX(-baseTranslation - mBelowStackSpace - shiftTranslation); break; } } else if (position > 1) { view.setAlpha(0f); } }
From source file:edward.com.recyclerview.BaseItemAnimator.java
void reset(View v) { v.setAlpha(1);//from w w w. j a va 2 s.c o m v.setScaleY(1); v.setScaleX(1); v.setTranslationY(0); v.setTranslationX(0); v.setRotation(0); v.setRotationY(0); v.setRotationX(0); v.setPivotX(v.getMeasuredWidth() / 2); v.setPivotY(v.getMeasuredHeight() / 2); v.animate().setInterpolator(null); }
From source file:com.android2ee.recyclerview.itemanimator.PendingItemAnimator.java
void reset(View v) { ViewCompat.setAlpha(v, 1);//from w ww . j a va 2 s. co m ViewCompat.setScaleY(v, 1); ViewCompat.setScaleX(v, 1); ViewCompat.setTranslationY(v, 0); ViewCompat.setTranslationX(v, 0); ViewCompat.setRotation(v, 0); ViewCompat.setRotationY(v, 0); ViewCompat.setRotationX(v, 0); v.setPivotX(v.getMeasuredWidth() / 2); v.setPivotY(v.getMeasuredHeight() / 2); ViewCompat.animate(v).setInterpolator(null); }
From source file:com.nkahoang.screenstandby.Main.java
@SuppressLint("NewApi") @Override//from ww w. j a va2 s .co m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); if (!prefs.getBoolean("wizardRun", false)) { Intent i = new Intent(this, com.nkahoang.screenstandby.AutoSettingWizard.class); this.startActivity(i); this.finish(); } animFlippingWholePage = (ObjectAnimator) AnimatorInflater.loadAnimator(Main.this, R.animator.flipping_whole_page); animFlippingRight = (ObjectAnimator) AnimatorInflater.loadAnimator(Main.this, R.animator.flipping_right); animFlippingLeft = (ObjectAnimator) AnimatorInflater.loadAnimator(Main.this, R.animator.flipping_left); animFlippingBack = (ObjectAnimator) AnimatorInflater.loadAnimator(Main.this, R.animator.flipping_back); animFlippingBackFromLeft = (ObjectAnimator) AnimatorInflater.loadAnimator(Main.this, R.animator.flipping_back_from_left); animZoomingOut = (AnimatorSet) AnimatorInflater.loadAnimator(Main.this, R.animator.zoomout); animZoomingIn = (AnimatorSet) AnimatorInflater.loadAnimator(Main.this, R.animator.zoomin); Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this)); setContentView(useMetro ? R.layout.activity_main : R.layout.activity_main_alt); View rootView = this.findViewById(R.id.rootView); animFlippingWholePage.setTarget(rootView); if (!useMetro) animFlippingWholePage.setDuration(0); if (android.os.Build.VERSION.SDK_INT >= 11) { rootView.setPivotX(0); rootView.setPivotY(0); } AnimatorProxy.wrap(rootView).setPivotX(0); AnimatorProxy.wrap(rootView).setPivotY(0); mPager = (ViewPager) findViewById(R.id.mainpager); mPagerAdapter = new MainPagerAdapter(this.getSupportFragmentManager()); mPager.setAdapter(mPagerAdapter); final TextView txtTitle = ((TextView) this.findViewById(R.id.txtTitle)); txtTitle.setTypeface(useMetro ? typefaceLight : typeface); final Button txtTitleNext = ((Button) this.findViewById(R.id.txtTitleNex)); txtTitleNext.setTypeface(typefaceLight); txtTitleNext.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mPager.getCurrentItem() < (NUM_PAGES - 1)) { mPager.setCurrentItem(mPager.getCurrentItem() + 1); } } }); final View indicator1 = Main.this.findViewById(R.id.indicator1); final View indicator2 = Main.this.findViewById(R.id.indicator2); final View indicator3 = Main.this.findViewById(R.id.indicator3); mPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageScrollStateChanged(int arg0) { // TODO Auto-generated method stub } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { // TODO Auto-generated method stub } @Override public void onPageSelected(int arg0) { txtTitle.setText(mPagerAdapter.getPageTitle(arg0)); txtTitleNext.setText(mPagerAdapter.getPageTitle(arg0 + 1)); int selected = useMetro ? R.drawable.circleindicator_selected : R.drawable.barindicator_selected; int normal = useMetro ? R.drawable.circleindicator : R.drawable.barindicator; indicator1.setBackgroundResource(arg0 == 0 ? selected : normal); indicator2.setBackgroundResource(arg0 == 1 ? selected : normal); indicator3.setBackgroundResource(arg0 == 2 ? selected : normal); } }); if (!useMetro) { ((ImageButton) this.findViewById(R.id.btnBackToMain)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mPager.setCurrentItem(0); } }); } ImageButton btnOverflows = (ImageButton) this.findViewById(R.id.btnOverflows); btnOverflows.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Main.this.openOptionsMenu(); } }); ImageButton btnSettings = (ImageButton) this.findViewById(R.id.btnSettings); btnSettings.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { openSettings(); } }); ImageButton btnVideoClip = (ImageButton) this.findViewById(R.id.btnVidClip); btnVideoClip.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { openVideoClip(); } }); ImageButton btnTroubleshooting = (ImageButton) this.findViewById(R.id.btntroubleshooting); btnTroubleshooting.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { animFlippingWholePage.start(); animFlippingWholePage.removeAllListeners(); animFlippingWholePage.addListener(new AnimatorListener() { @Override public void onAnimationCancel(Animator arg0) { } @Override public void onAnimationEnd(Animator arg0) { Intent intent = new Intent(Main.this, TroubleshootingActivity.class); startActivity(intent); animFlippingWholePage.reverse(); } @Override public void onAnimationRepeat(Animator arg0) { } @Override public void onAnimationStart(Animator arg0) { } }); } }); /* if (!ChangeLogHandler.IsChangeLogRead(this)) { ChangeLogHandler.ShowChangelog(this); } */ //warning(); }
From source file:com.mwang.irregulargridview.DynamicItemAnimator.java
public boolean animateMove(final RecyclerView.ViewHolder holder, int fromX, int fromY, int toX, int toY, int fromWidth, int fromHeight, int toWidth, int toHeight) { final View view = holder.itemView; fromX += ViewCompat.getTranslationX(holder.itemView); fromY += ViewCompat.getTranslationY(holder.itemView); resetAnimation(holder);/*from ww w .j a v a 2 s . c o m*/ int deltaX = toX - fromX; int deltaY = toY - fromY; float scaleX = (float) toWidth / fromWidth; float scaleY = (float) toHeight / fromHeight; if (scaleX == 0) scaleX = 1; if (scaleY == 0) scaleY = 1; if (deltaX == 0 && deltaY == 0 && scaleX == 1 && scaleY == 1) { dispatchMoveFinished(holder); return false; } view.setPivotX(0); view.setPivotY(0); if (scaleX != 1) { ViewCompat.setScaleX(view, 1 / scaleX); } if (scaleY != 1) { ViewCompat.setScaleY(view, 1 / scaleY); } if (deltaX != 0) { ViewCompat.setTranslationX(view, -deltaX); } if (deltaY != 0) { ViewCompat.setTranslationY(view, -deltaY); } mPendingMoves.add(new MoveInfo(holder, fromX, fromY, toX, toY, fromWidth, fromHeight, toWidth, toHeight)); return true; }
From source file:org.protocoderrunner.apprunner.api.PUI.java
@ProtocoderScript @APIMethod(description = "Scales and moves a view to a given position and size", example = "") @APIParam(params = { "View", "x", "y", "w", "h" }) public void amplify(View v, float x, float y, float w, float h) { this.move(v, x, y); float pX = v.getPivotX(); float pY = v.getPivotY(); v.setPivotX(0);/*ww w.j a v a 2s . c om*/ v.setPivotY(0); float sX = w / v.getWidth(); float sY = h / v.getHeight(); this.scale(v, sX, sY); v.setPivotX(pX); v.setPivotY(pY); }