Java Code Examples for android.view.View.setPivotX()

The following are Jave code examples for showing how to use setPivotX() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Expert-Android-Programming   File: LoginActivity.java   Source Code and License Vote up 7 votes
private void hideHint(final View view) {
    view.setPivotX(0);
    view.setPivotY(view.getHeight());

    Animator iconAnim = ObjectAnimator.ofPropertyValuesHolder(view,
            PropertyValuesHolder.ofFloat(View.ALPHA, 1f, 0f),
            PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f, 0f));
    iconAnim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            view.setVisibility(View.INVISIBLE);
        }
    });
    iconAnim.start();
}
 
Example 2
Project: GmArchMvvm   File: VegaLayoutManager.java   Source Code and License Vote up 7 votes
/**
 * 初始化的时候,layout子View
 */
private void layoutItemsOnCreate(RecyclerView.Recycler recycler) {
    int itemCount = getItemCount();
    for (int i = 0; i < itemCount; i++) {
        View childView = recycler.getViewForPosition(i);
        addView(childView);
        measureChildWithMargins(childView, View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
        layoutItem(childView, locationRects.get(i));
        attachedItems.put(i, true);
        childView.setPivotY(0);
        childView.setPivotX(childView.getMeasuredWidth() / 2);

        if (locationRects.get(i).top > getHeight()) {
            break;
        }
    }
}
 
Example 3
Project: Melophile   File: BackgroundScale.java   Source Code and License Vote up 6 votes
@Override
public Animator onAppear(ViewGroup sceneRoot, View view,
                         TransitionValues startValues,
                         TransitionValues endValues) {
    view.setPivotX(view.getWidth());
    view.setPivotY(view.getHeight()/2);
    return ObjectAnimator.ofFloat(view,View.SCALE_X,0,1).setDuration(400);
}
 
Example 4
Project: AndroidBasicLibs   File: ScaleInOutTransformer.java   Source Code and License Vote up 6 votes
@Override
protected void onTransform(View view, float position) {
	view.setPivotX(position < 0 ? 0 : view.getWidth());
	view.setPivotY(view.getHeight() / 2f);
	float scale = position < 0 ? 1f + position : 1f - position;
	view.setScaleX(scale);
	view.setScaleY(scale);
}
 
Example 5
Project: GitHub   File: FlipVerticalTransformer.java   Source Code and License Vote up 6 votes
@Override
protected void onTransform(View view, float position) {
	final float rotation = -180f * position;

	view.setAlpha(rotation > 90f || rotation < -90f ? 0f : 1f);
	view.setPivotX(view.getWidth() * 0.5f);
	view.setPivotY(view.getHeight() * 0.5f);
	view.setRotationX(rotation);
}
 
Example 6
Project: Views   File: Pivot.java   Source Code and License Vote up 6 votes
public void setOn(View view) {
    if (axis == AXIS_X) {
        switch (pivotPoint) {
            case PIVOT_CENTER:
                view.setPivotX(view.getWidth() * 0.5f);
                break;
            case PIVOT_MAX:
                view.setPivotX(view.getWidth());
                break;
            default:
                view.setPivotX(pivotPoint);
                break;
        }
        return;
    }

    if (axis == AXIS_Y) {
        switch (pivotPoint) {
            case PIVOT_CENTER:
                view.setPivotY(view.getHeight() * 0.5f);
                break;
            case PIVOT_MAX:
                view.setPivotY(view.getHeight());
                break;
            default:
                view.setPivotY(pivotPoint);
                break;
        }
    }
}
 
Example 7
Project: GitHub   File: ScaleInOutTransformer.java   Source Code and License Vote up 6 votes
@Override
protected void onTransform(View view, float position) {
	view.setPivotX(position < 0 ? 0 : view.getWidth());
	view.setPivotY(view.getHeight() / 2f);
	float scale = position < 0 ? 1f + position : 1f - position;
	view.setScaleX(scale);
	view.setScaleY(scale);
}
 
Example 8
Project: ImageLooper   File: AccordionTransformer.java   Source Code and License Vote up 6 votes
@Override
protected void onTransform(View page, float position) {
    page.setPivotX(position < 0 ? 0 : page.getWidth());
    if (position < -1) {//[-infinity,-1)
        page.setPivotX(page.getWidth());
    }else if (position < 0) {//[-1,0)
        page.setPivotX(0);
    }else {//[0,+infinity)
        page.setPivotX(page.getWidth());
    }
    page.setScaleX(position < 0 ? 1f + position : 1f - position);
}
 
Example 9
Project: ImitateZHRB   File: RotateDownTransformer.java   Source Code and License Vote up 6 votes
@Override
protected void onTransform(View view, float position) {
	final float width = view.getWidth();
	final float height = view.getHeight();
	final float rotation = ROT_MOD * position * -1.25f;

	view.setPivotX(width * 0.5f);
	view.setPivotY(height);
	view.setRotation(rotation);
}
 
Example 10
Project: Mybilibili   File: FlipVerticalTransformer.java   Source Code and License Vote up 6 votes
@Override
protected void onTransform(View view, float position) {
	final float rotation = -180f * position;

	view.setAlpha(rotation > 90f || rotation < -90f ? 0f : 1f);
	view.setPivotX(view.getWidth() * 0.5f);
	view.setPivotY(view.getHeight() * 0.5f);
	view.setRotationX(rotation);
}
 
Example 11
Project: ECardFlow   File: CardFlowTransformer.java   Source Code and License Vote up 6 votes
@Override
public void transformPage(View page, float position) {
    final float height = page.getHeight();
    final float width = page.getWidth();
    page.setPivotY(0.5f * height);
    page.setPivotX(0.5f * width);
    if (position >= -2 && position <= 2) {
        float mFraction = mDirection * (float) Math.abs(Math.sin(Math.PI * position));
        page.setRotationY(mFraction * mMaxRotateY);
        page.setScaleX(PAGE_SCALE);
        page.setScaleY(PAGE_SCALE);
    }
}
 
Example 12
Project: LoginConcept   File: FlipTransformer.java   Source Code and License Vote up 6 votes
public void transformPage(View view, float position){
    int pageWidth = view.getWidth();
    int pageHeight = view.getHeight();
    view.setPivotX((float) pageWidth / 2);
    view.setPivotY((float) (pageHeight + pageWidth * distanceToCentreFactor));


    if(position < -1){ //[-infinity,1)
        view.setRotation(0);
        view.setAlpha(0);
    }else if(position <= 1){ //[-1,1]
        view.setTranslationX((-position) * pageWidth); //shift the view over
        if(movingForward) {
            if (position >= 0) {
                view.setRotation(position * (180 - degrees)); //rotate it
                // Fade the page relative to its distance from the center
                view.setAlpha(Math.max(minAlpha, 1 - Math.abs(position) / 3));
            } else {
                Log.d("Flip", Float.toString(position));
                view.setAlpha(1 + position);
            }
        }else if(position<=0){
            view.setRotation(position * (180 - degrees)); //rotate it
            // Fade the page relative to its distance from the center
            view.setAlpha(Math.max(minAlpha, 1 - Math.abs(position) / 3));
        }else{
            Log.d("Flip", Float.toString(position));
            view.setAlpha(1 - position);
        }
    }else{ //(1, +infinity]
        view.setRotation(0);
        view.setAlpha(0);
    }
}
 
Example 13
Project: GitHub   File: ZoomOutTranformer.java   Source Code and License Vote up 6 votes
@Override
protected void onTransform(View view, float position) {
	final float scale = 1f + Math.abs(position);
	view.setScaleX(scale);
	view.setScaleY(scale);
	view.setPivotX(view.getWidth() * 0.5f);
	view.setPivotY(view.getHeight() * 0.5f);
	view.setAlpha(position < -1f || position > 1f ? 0f : 1f - (scale - 1f));
	if(position == -1){
		view.setTranslationX(view.getWidth() * -1);
	}
}
 
Example 14
Project: BannerView   File: FlipVerticalTransformer.java   Source Code and License Vote up 6 votes
@Override
protected void onTransform(View view, float position) {
	final float rotation = -180f * position;

	view.setAlpha(rotation > 90f || rotation < -90f ? 0f : 1f);
	view.setPivotX(view.getWidth() * 0.5f);
	view.setPivotY(view.getHeight() * 0.5f);
	view.setRotationX(rotation);
}
 
Example 15
Project: BannerView   File: ZoomOutTransformer.java   Source Code and License Vote up 6 votes
@Override
protected void onTransform(View view, float position) {
	final float scale = 1f + Math.abs(position);
	view.setScaleX(scale);
	view.setScaleY(scale);
	view.setPivotX(view.getWidth() * 0.5f);
	view.setPivotY(view.getHeight() * 0.5f);
	view.setAlpha(position < -1f || position > 1f ? 0f : 1f - (scale - 1f));
	if(position == -1){
		view.setTranslationX(view.getWidth() * -1);
	}
}
 
Example 16
Project: Mybilibili   File: ZoomOutTranformer.java   Source Code and License Vote up 6 votes
@Override
protected void onTransform(View view, float position) {
	final float scale = 1f + Math.abs(position);
	view.setScaleX(scale);
	view.setScaleY(scale);
	view.setPivotX(view.getWidth() * 0.5f);
	view.setPivotY(view.getHeight() * 0.5f);
	view.setAlpha(position < -1f || position > 1f ? 0f : 1f - (scale - 1f));
	if(position == -1){
		view.setTranslationX(view.getWidth() * -1);
	}
}
 
Example 17
Project: ImitateZHRB   File: AccordionTransformer.java   Source Code and License Vote up 5 votes
@Override
protected void onTransform(View view, float position) {
	view.setPivotX(position < 0 ? 0 : view.getWidth());
	view.setScaleX(position < 0 ? 1f + position : 1f - position);
}
 
Example 18
Project: PageTransformerHelp   File: AccordionTransformer.java   Source Code and License Vote up 5 votes
@Override
protected void onTransform(View view, float position) {
	view.setPivotX(position < 0 ? 0 : view.getWidth());
	view.setScaleX(position < 0 ? 1f + position : 1f - position);
}
 
Example 19
Project: LuaViewPlayground   File: ViewHelper.java   Source Code and License Vote up 5 votes
static void setPivotX(View view, float pivotX) {
    view.setPivotX(pivotX);
}
 
Example 20
Project: weex-3d-map   File: WXAnimationModule.java   Source Code and License Vote up 5 votes
private static @Nullable
ObjectAnimator createAnimator(@NonNull WXAnimationBean animation, final View target) {
  if(target == null){
    return null;
  }
  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);
    final IntEvaluator intEvaluator=new IntEvaluator();
    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)));
      }
      if (!TextUtils.isEmpty(style.height)) {
        listener.setHeight(layoutParams.height,
                           (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.height)));
      }
      animator.addUpdateListener(listener);
    }
    return animator;
  } else {
    return null;
  }
}