android.view.View#setPivotX ( )源码实例Demo

下面列出了android.view.View#setPivotX ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: BannerPager   文件: BaseTransformer.java
/**
     * Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)}.
     * <p>
     * The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
     * not modify the same page properties. For instance changing from a transformation that applies rotation to a
     * transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
     * alpha.
     *
     * @param page     Apply the transformation to this page
     * @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
     *                 center. 1 is one full page position to the right, and -1 is one page position to the left.
     */
    protected void onPreTransform(View page, float position) {
        final float width = page.getWidth();

        page.setRotationX(0);
        page.setRotationY(0);
        page.setRotation(0);
        page.setScaleX(1);
        page.setScaleY(1);
        page.setPivotX(0);
        page.setPivotY(0);
        page.setTranslationY(0);
        page.setTranslationX(isPagingEnabled() ? 0f : -width * position);

        if (hideOffscreenPages()) {
            page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
//			page.setEnabled(false);
        } else {
//			page.setEnabled(true);
            page.setAlpha(1f);
        }
    }
 
源代码2 项目: UltimateAndroid   文件: ABaseTransformer.java
/**
 * Called each {@link #transformPage(android.view.View, float)} before {{@link #onTransform(android.view.View, float)} is called.
 * 
 * @param view
 * @param position
 */
protected void onPreTransform(View view, float position) {
	final float width = view.getWidth();

	view.setRotationX(0);
	view.setRotationY(0);
	view.setRotation(0);
	view.setScaleX(1);
	view.setScaleY(1);
	view.setPivotX(0);
	view.setPivotY(0);
	view.setTranslationY(0);
	view.setTranslationX(isPagingEnabled() ? 0f : -width * position);

	if (hideOffscreenPages()) {
		view.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
	} else {
		view.setAlpha(1f);
	}
}
 
源代码3 项目: CoolViewPager   文件: VerticalRotateTransformer.java
@Override
public void transformPage(View page, float position) {
    page.setTranslationX(page.getWidth() * -position);
    page.setTranslationY(page.getHeight() * position);
    page.setCameraDistance(10000F);
    if(position < -1){
        page.setRotationX(0F);
    }else if(position <= 0){
        page.setPivotX(page.getWidth()/2);
        page.setPivotY(page.getHeight());
        page.setRotationX(MAX_ROTATE * -position);
    }else if(position <= 1){
        page.setPivotX(page.getWidth()/2);
        page.setPivotY(0F);
        page.setRotationX(MAX_ROTATE * -position);
    }else {
        page.setRotationX(0F);
    }
}
 
public void slideBack(Animator.AnimatorListener listener) {
    View movingFragmentView = mFirstFragment.getView();
    movingFragmentView.setPivotY(movingFragmentView.getHeight()/2);
    movingFragmentView.setPivotX(movingFragmentView.getWidth() / 2);

    PropertyValuesHolder rotateX = PropertyValuesHolder.ofFloat("rotationX", 40f);
    PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 0.8f);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 0.8f);
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0.5f);
    ObjectAnimator movingFragmentAnimator = ObjectAnimator.ofPropertyValuesHolder(movingFragmentView, rotateX, scaleX, scaleY, alpha);

    ObjectAnimator movingFragmentRotator = ObjectAnimator.ofFloat(movingFragmentView, "rotationX", 0);
    movingFragmentRotator.setStartDelay(mContext.getResources().getInteger(R.integer.half_slide_up_down_duration));

    AnimatorSet s = new AnimatorSet();
    s.playTogether(movingFragmentAnimator, movingFragmentRotator);
    s.addListener(listener);
    s.start();
}
 
源代码5 项目: TurboLauncher   文件: PagedView.java
@Override
public void screenScrolled(View v, int i, float scrollProgress) {
    float rotation =
            (mUp ? TRANSITION_SCREEN_ROTATION : -TRANSITION_SCREEN_ROTATION) * scrollProgress;

    float translationX = v.getMeasuredWidth() * scrollProgress;

    float rotatePoint =
            (v.getMeasuredWidth() * 0.5f) /
                    (float) Math.tan(Math.toRadians((double) (TRANSITION_SCREEN_ROTATION * 0.5f)));

    v.setPivotX(v.getMeasuredWidth() * 0.5f);
    if (mUp) {
        v.setPivotY(-rotatePoint);
    } else {
        v.setPivotY(v.getMeasuredHeight() + rotatePoint);
    }
    v.setRotation(rotation);
    v.setTranslationX(translationX);
}
 
源代码6 项目: OmegaRecyclerView   文件: RotateDownTransformer.java
@Override
public void transformItem(View view, float position, boolean isHorizontal, int scrolled) {
    float rotation;
    float width = view.getWidth();
    float height = view.getHeight();
    if (isHorizontal) {
        rotation = ROT_MOD * position * -1.25f;
        view.setPivotX(width * 0.5f);
        view.setPivotY(height);
        view.setTranslationX(0f);
    } else {
        rotation = ROT_MOD * position;
        view.setPivotY(height * 0.5f);
        view.setPivotX(view.getWidth());
        view.setTranslationY(0f);
    }
    view.setRotation(rotation);
}
 
源代码7 项目: EasyTabs   文件: EasyZoomInTransformer.java
@Override
protected void onTransform(View view, float position) {
	final float scale = position < 0 ? position + 1f : Math.abs(1f - 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));
}
 
源代码8 项目: HomeApplianceMall   文件: ScaleInOutTransformer.java
@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);
}
 
@Override
protected void onTransform(View view, float position) {
    final float rotation = 180f * position;

    view.setAlpha(rotation > 90f || rotation < -90f ? 0 : 1);
    view.setPivotX(view.getWidth() * 0.5f);
    view.setPivotY(view.getHeight() * 0.5f);
    view.setRotationY(rotation);
}
 
源代码10 项目: WanAndroid   文件: TabletTransformer.java
@Override
protected void onTransform(View view, float position) {
	final float rotation = (position < 0 ? 30f : -30f) * Math.abs(position);

	view.setTranslationX(getOffsetXForRotation(rotation, view.getWidth(), view.getHeight()));
	view.setPivotX(view.getWidth() * 0.5f);
	view.setPivotY(0);
	view.setRotationY(rotation);
}
 
源代码11 项目: WanAndroid   文件: RotateUpTransformer.java
@Override
protected void onTransform(View view, float position) {
	final float width = view.getWidth();
	final float rotation = ROT_MOD * position;

	view.setPivotX(width * 0.5f);
	view.setPivotY(0f);
	view.setTranslationX(0f);
	view.setRotation(rotation);
}
 
源代码12 项目: Banner   文件: BackgroundToForegroundTransformer.java
@Override
protected void onTransform(View view, float position) {
    final float height = view.getHeight();
    final float width = view.getWidth();
    final float scale = min(position < 0 ? 1f : Math.abs(1f - position), 0.5f);

    view.setScaleX(scale);
    view.setScaleY(scale);
    view.setPivotX(width * 0.5f);
    view.setPivotY(height * 0.5f);
    view.setTranslationX(position < 0 ? width * position : -width * position * 0.25f);
}
 
@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);
}
 
源代码14 项目: JazzyListView   文件: GrowEffect.java
@Override
public void initView(View item, int position, int scrollDirection) {
    item.setPivotX(item.getWidth() / 2);
    item.setPivotY(item.getHeight() / 2);
    item.setScaleX(INITIAL_SCALE_FACTOR);
    item.setScaleY(INITIAL_SCALE_FACTOR);
}
 
@Override
protected void onTransform(View view, float position) {
	final float height = view.getHeight();
	final float width = view.getWidth();
	final float scale = min(position < 0 ? 1f : Math.abs(1f - position), 0.5f);

	view.setScaleX(scale);
	view.setScaleY(scale);
	view.setPivotX(width * 0.5f);
	view.setPivotY(height * 0.5f);
	view.setTranslationX(position < 0 ? width * position : -width * position * 0.25f);
}
 
源代码16 项目: carouselview   文件: CoverFlowViewTransformer.java
@Override
public void transform(View view, float position) {
    int width = view.getMeasuredWidth(), height = view.getMeasuredHeight();
    view.setPivotX(width / 2.0f);
    view.setPivotY(height / 2.0f);
    view.setTranslationX(width * position * mOffsetXPercent);
    view.setRotationY(Math.signum(position) * (float)(Math.log(Math.abs(position) + 1) / Math.log(3) * - mYProjection));
    view.setScaleY(1 + mScaleYFactor * Math.abs(position));
}
 
源代码17 项目: Hillffair17   文件: RotateDownPageTransformer.java
private 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);
}
 
源代码18 项目: Banner   文件: CubeInTransformer.java
@Override
protected void onTransform(View view, float position) {
    // Rotate the fragment on the left or right edge
    view.setPivotX(position > 0 ? 0 : view.getWidth());
    view.setPivotY(0);
    view.setRotationY(-90f * position);
}
 
private void showHint(View view) {
    view.setPivotX(0);
    view.setPivotY(view.getHeight());

    if (view.getVisibility() == View.INVISIBLE) {
        view.setVisibility(View.VISIBLE);
        Animator iconAnim = ObjectAnimator.ofPropertyValuesHolder(view,
                PropertyValuesHolder.ofFloat(View.ALPHA, 0f, 1f),
                PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f, 1f));
        iconAnim.start();
    }

}
 
源代码20 项目: ViewPager   文件: RotatePageTransformer.java
private void rotate(View view, float rotation) {
    view.setPivotX(view.getWidth()*0.5f);
    view.setPivotY(view.getHeight());
    view.setRotation(rotation);
}
 
 方法所在类
 同类方法