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

The following are Jave code examples for showing how to use setPivotY() 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: ImitateZHRB   File: ABaseTransformer.java   Source Code and License Vote up 7 votes
/**
	 * 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);
		}
	}
 
Example 2
Project: GitHub   File: UltraDepthScaleTransformer.java   Source Code and License Vote up 7 votes
@Override
public void transformPage(View view, float position) {
    final float scale = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
    final float rotation = MAX_ROTATION * Math.abs(position);

    if (position <= 0f) {
        view.setTranslationX(view.getWidth() * -position * 0.19f);
        view.setPivotY(0.5f * view.getHeight());
        view.setPivotX(0.5f * view.getWidth());
        view.setScaleX(scale);
        view.setScaleY(scale);
        view.setRotationY(rotation);
    } else if (position <= 1f) {
        view.setTranslationX(view.getWidth() * -position * 0.19f);
        view.setPivotY(0.5f * view.getHeight());
        view.setPivotX(0.5f * view.getWidth());
        view.setScaleX(scale);
        view.setScaleY(scale);
        view.setRotationY(-rotation);
    }
}
 
Example 3
Project: AndroidViewPagerRxJava   File: ABaseTransformer.java   Source Code and License Vote up 7 votes
/**
 * 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);
	}
}
 
Example 4
Project: MarsBootProject   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: boohee_v5.6   File: ZoomOutTranformer.java   Source Code and License Vote up 6 votes
protected void onTransform(View view, float position) {
    float scale = 1.0f + Math.abs(position);
    view.setScaleX(scale);
    view.setScaleY(scale);
    view.setPivotX(((float) view.getWidth()) * 0.5f);
    view.setPivotY(((float) view.getHeight()) * 0.5f);
    float f = (position < -1.0f || position > 1.0f) ? 0.0f : 1.0f - (scale - 1.0f);
    view.setAlpha(f);
    if (position == -1.0f) {
        view.setTranslationX((float) (view.getWidth() * -1));
    }
}
 
Example 6
Project: AndroidViewPagerRxJava   File: DepthPageTransformer.java   Source Code and License Vote up 6 votes
@Override
protected void onTransform(View view, float position) {
	if (position <= 0f) {
		view.setTranslationX(0f);
		view.setScaleX(1f);
		view.setScaleY(1f);
	} else if (position <= 1f) {
		final float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
		view.setAlpha(1 - position);
		view.setPivotY(0.5f * view.getHeight());
		view.setTranslationX(view.getWidth() * -position);
		view.setScaleX(scaleFactor);
		view.setScaleY(scaleFactor);
	}
}
 
Example 7
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 8
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 9
Project: BannerView   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 10
Project: GitHub   File: FlipHorizontalTransformer.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 ? 0 : 1);
    view.setPivotX(view.getWidth() * 0.5f);
    view.setPivotY(view.getHeight() * 0.5f);
    view.setRotationY(rotation);
}
 
Example 11
Project: PageTransformerHelp   File: CubeInTransformer.java   Source Code and License Vote up 6 votes
@Override
protected void onTransform(View view, float position) {
	Log.e("cubein",view.getWidth()+":"+view.getHeight());
	// Rotate the fragment on the left or right edge
	view.setPivotX(position > 0 ? 0 : view.getWidth());
	view.setPivotY(0);
	view.setRotationY(-90f * position);
}
 
Example 12
Project: GitHub   File: TabletTransformer.java   Source Code and License Vote up 6 votes
@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);
}
 
Example 13
Project: Mybilibili   File: FlipHorizontalTransformer.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 ? 0 : 1);
	view.setPivotX(view.getWidth() * 0.5f);
	view.setPivotY(view.getHeight() * 0.5f);
	view.setRotationY(rotation);
}
 
Example 14
Project: Mybilibili   File: DepthPageTransformer.java   Source Code and License Vote up 6 votes
@Override
protected void onTransform(View view, float position) {
	if (position <= 0f) {
		view.setTranslationX(0f);
		view.setScaleX(1f);
		view.setScaleY(1f);
	} else if (position <= 1f) {
		final float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
		view.setAlpha(1 - position);
		view.setPivotY(0.5f * view.getHeight());
		view.setTranslationX(view.getWidth() * -position);
		view.setScaleX(scaleFactor);
		view.setScaleY(scaleFactor);
	}
}
 
Example 15
Project: GitHub   File: ForegroundToBackgroundTransformer.java   Source Code and License Vote up 6 votes
@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);
}
 
Example 16
Project: AndroidViewPagerRxJava   File: ZoomOutSlideTransformer.java   Source Code and License Vote up 6 votes
@Override
protected void onTransform(View view, float position) {
	if (position >= -1 || position <= 1) {
		// Modify the default slide transition to shrink the page as well
		final float height = view.getHeight();
		final float width = view.getWidth();
		final float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
		final float vertMargin = height * (1 - scaleFactor) / 2;
		final float horzMargin = width * (1 - scaleFactor) / 2;

		// Center vertically
		view.setPivotY(0.5f * height);
		view.setPivotX(0.5f * width);

		if (position < 0) {
			view.setTranslationX(horzMargin - vertMargin / 2);
		} else {
			view.setTranslationX(-horzMargin + vertMargin / 2);
		}

		// Scale the page down (between MIN_SCALE and 1)
		view.setScaleX(scaleFactor);
		view.setScaleY(scaleFactor);

		// Fade the page relative to its size.
		view.setAlpha(MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA));
	}
}
 
Example 17
Project: weex-3d-map   File: WXSliderNeighbor.java   Source Code and License Vote up 5 votes
@Override
public void transformPage(View page, float position) {
    View realView = ((ViewGroup)page).getChildAt(0);
    if(realView == null){
        return;
    }
    float alpha, scale;

    if(position <= (-mAdapter.getRealCount() + 1)) {
        position = position + mAdapter.getRealCount();
    }
    if(position >= mAdapter.getRealCount() - 1) {
        position = position - mAdapter.getRealCount();
    }

    if (position >= -1 && position <= 1) {
        float factor = Math.abs(Math.abs(position) - 1);
        scale = mNerghborScale + factor * (WX_DEFAULT_MAIN_NEIGHBOR_SCALE-mNerghborScale);
        alpha = (1-mNerghborAlpha) * factor + mNerghborAlpha;
        int delta = page.getMeasuredWidth()-realView.getMeasuredWidth();
        float translation = ((page.getMeasuredWidth()-realView.getMeasuredWidth()*WX_DEFAULT_MAIN_NEIGHBOR_SCALE)- WXViewUtils.getRealPxByWidth(DEFAULT_NEIGHBOR_SPACE)*2)/2;
        if(mViewPager.getCurrentItem() != mAdapter.getItemPosition(page)){
            if(position > 0){
                realView.setPivotX(0);
                realView.setTranslationX(-delta);
                page.setTranslationX(-translation);
            }else{
                realView.setPivotX(realView.getMeasuredWidth());
                realView.setTranslationX(delta);
                page.setTranslationX(translation);
            }
        }else{
            realView.setPivotX(realView.getMeasuredWidth()/2);
            page.setTranslationX(0);
            realView.setTranslationX(0);
        }

        realView.setPivotY(realView.getMeasuredHeight()/2);

        realView.setAlpha(alpha);
        realView.setScaleX(scale);
        realView.setScaleY(scale);
    }
}
 
Example 18
Project: GitHub   File: CubeOutTransformer.java   Source Code and License Vote up 5 votes
@Override
protected void onTransform(View view, float position) {
	view.setPivotX(position < 0f ? view.getWidth() : 0f);
	view.setPivotY(view.getHeight() * 0.5f);
	view.setRotationY(90f * position);
}
 
Example 19
Project: AndroidBasicLibs   File: CubeOutTransformer.java   Source Code and License Vote up 5 votes
@Override
protected void onTransform(View view, float position) {
	view.setPivotX(position < 0f ? view.getWidth() : 0f);
	view.setPivotY(view.getHeight() * 0.5f);
	view.setRotationY(90f * position);
}
 
Example 20
Project: Mybilibili   File: CubeOutTransformer.java   Source Code and License Vote up 5 votes
@Override
protected void onTransform(View view, float position) {
	view.setPivotX(position < 0f ? view.getWidth() : 0f);
	view.setPivotY(view.getHeight() * 0.5f);
	view.setRotationY(90f * position);
}