Java Code Examples for android.view.View#setCameraDistance()

The following examples show how to use android.view.View#setCameraDistance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VerticalRotateTransformer.java    From CoolViewPager with Apache License 2.0 6 votes vote down vote up
@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);
    }
}
 
Example 2
Source File: Flip.java    From Trebuchet with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void screenScrolled(View v, float progress) {
    float rotation = -180.0f * Math.max(-1f, Math.min(1f, progress));

    v.setCameraDistance(mPagedView.mDensity * CAMERA_DISTANCE);
    v.setPivotX(v.getMeasuredWidth() * 0.5f);
    v.setPivotY(v.getMeasuredHeight() * 0.5f);
    v.setRotationY(rotation);

    if (progress >= -0.5f && progress <= 0.5f) {
        v.setTranslationX(v.getMeasuredWidth() * progress);
        if (v.getVisibility() != View.VISIBLE) {
            v.setVisibility(View.VISIBLE);
        }
    } else {
        v.setTranslationX(v.getMeasuredWidth() * -10f);
    }
}
 
Example 3
Source File: PhoneTabSwitcherLayout.java    From ChromeLikeTabSwitcher with Apache License 2.0 6 votes vote down vote up
/**
 * Tilts the tabs, when overshooting at the start.
 *
 * @param angle
 *         The angle, the tabs should be rotated by, in degrees as a {@link Float} value
 */
private void tiltOnStartOvershoot(final float angle) {
    ItemIterator iterator =
            new ItemIterator.Builder(getTabSwitcher(), tabViewRecycler).create();
    AbstractItem item;

    while ((item = iterator.next()) != null) {
        View view = item.getView();

        if (item.getIndex() == 0) {
            view.setCameraDistance(maxCameraDistance);
            getArithmetics().setPivot(Axis.DRAGGING_AXIS, item, getArithmetics()
                    .getPivot(Axis.DRAGGING_AXIS, item, DragState.OVERSHOOT_START));
            getArithmetics().setPivot(Axis.ORTHOGONAL_AXIS, item, getArithmetics()
                    .getPivot(Axis.ORTHOGONAL_AXIS, item, DragState.OVERSHOOT_START));
            getArithmetics().setRotation(Axis.ORTHOGONAL_AXIS, item, angle);
        } else if (item.isInflated()) {
            item.getView().setVisibility(View.INVISIBLE);
        }
    }
}
 
Example 4
Source File: RotateTransformer.java    From CoolViewPager with Apache License 2.0 6 votes vote down vote up
@Override
public void transformPage(View page, float position) {
    page.setCameraDistance(10000F);
    if(position < -1){
        /*page.setPivotX(page.getWidth());
        page.setPivotY(page.getHeight()/2);
        page.setRotationY(-MAX_ROTATE);*/
    }else if(position <= 0){
        page.setPivotX(page.getWidth());
        page.setPivotY(page.getHeight()/2);
        page.setRotationY(MAX_ROTATE * position);
    }else if(position <= 1){
        page.setPivotX(0F);
        page.setPivotY(page.getHeight()/2);
        page.setRotationY(MAX_ROTATE * position);
    }else {
        /*page.setPivotX(0F);
        page.setPivotY(page.getHeight()/2);
        page.setRotationY(MAX_ROTATE);*/
    }
}
 
Example 5
Source File: DepthCardTransformer.java    From BannerPager with Apache License 2.0 5 votes vote down vote up
@Override
protected void onTransform(View page, float position) {
    if (position < -1) {
        /* [-Infinity,-1)*/
        /*页面已经在屏幕左侧第一个*/
        page.setCameraDistance(10000);
        page.setPivotX(page.getWidth() / 2);
        page.setPivotY(page.getWidth());
        page.setRotationY(15);
    } else if (position <= 0) {
        /* [-1,0]*/
        /*页面从左侧进入或者向左侧滑出的状态*/
        page.setCameraDistance(10000);
        page.setPivotX(page.getWidth() / 2);
        page.setPivotY(page.getWidth());
        page.setRotationY(-15 + (1 - position) * 15);
    } else if (position <= 1) {
        /* (0,1]*/
        /*页面从右侧进入或者向右侧滑出的状态*/
        page.setCameraDistance(10000);
        page.setPivotX(page.getWidth() / 2);
        page.setPivotY(page.getWidth());
        page.setRotationY(-15 + (1 - position) * 15);
    } else if (position <= 2) {
        /*页面已经在屏幕右侧第一个*/
        page.setCameraDistance(10000);
        page.setPivotX(page.getWidth() / 2);
        page.setPivotY(page.getWidth());
        page.setRotationY(-15);
    }
}
 
Example 6
Source File: Cube.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void screenScrolled(View v, float progress) {
    float rotation = (cubIn ? 90.0f : -90.0f) * progress;

    if (cubIn) {
        v.setCameraDistance(mPagedView.mDensity * CAMERA_DISTANCE);
    }

    v.setPivotX(progress < 0 ? 0 : v.getMeasuredWidth());
    v.setPivotY(v.getMeasuredHeight() * 0.5f);
    v.setRotationY(rotation);
}
 
Example 7
Source File: FlipPageViewTransformer.java    From LoyalNativeSlider with MIT License 5 votes vote down vote up
@Override
protected void onTransform(View view, float position) {
    float percentage = 1 - Math.abs(position);
    if(Build.VERSION.SDK_INT >= 13){
        view.setCameraDistance(12000);
    }
    setVisibility(view, position);
    setTranslation(view);
    setSize(view, position, percentage);
    setRotation(view, position, percentage);
}
 
Example 8
Source File: FlipPageViewTransformer.java    From ImageSliderWithSwipes with Apache License 2.0 5 votes vote down vote up
@Override
protected void onTransform(View view, float position) {
    float percentage = 1 - Math.abs(position);
    if(Build.VERSION.SDK_INT >= 13){
        view.setCameraDistance(12000);
    }
    setVisibility(view, position);
    setTranslation(view);
    setSize(view, position, percentage);
    setRotation(view, position, percentage);
}
 
Example 9
Source File: SimplePageTransformer.java    From NanoIconPack with Apache License 2.0 5 votes vote down vote up
private void transformPageFlip(View view, float position) {
    float percentage = 1 - Math.abs(position);
    view.setCameraDistance(12000);
    setVisibility(view, position);
    setTranslation(view);
    setSize(view, position, percentage);
    setRotation(view, position, percentage);
}
 
Example 10
Source File: SpinnerTransformation.java    From Android-Image-Slider with Apache License 2.0 5 votes vote down vote up
@Override
public void transformPage(View page, float position) {

    page.setTranslationX(-position * page.getWidth());
    page.setCameraDistance(12000);

    if (position < 0.5 && position > -0.5) {
        page.setVisibility(View.VISIBLE);
    } else {
        page.setVisibility(View.INVISIBLE);
    }



    if (position < -1){     // [-Infinity,-1)
        // This page is way off-screen to the left.
        page.setAlpha(0);

    }
    else if (position <= 0) {    // [-1,0]
        page.setAlpha(1);
        page.setRotationY(900 *(1-Math.abs(position)+1));

    }
    else if (position <= 1) {    // (0,1]
        page.setAlpha(1);
        page.setRotationY(-900 *(1-Math.abs(position)+1));

    }
    else {    // (1,+Infinity]
        // This page is way off-screen to the right.
        page.setAlpha(0);

    }


}
 
Example 11
Source File: BaseViewManager.java    From react-native-GPay with MIT License 5 votes vote down vote up
private static void resetTransformProperty(View view) {
  view.setTranslationX(PixelUtil.toPixelFromDIP(0));
  view.setTranslationY(PixelUtil.toPixelFromDIP(0));
  view.setRotation(0);
  view.setRotationX(0);
  view.setRotationY(0);
  view.setScaleX(1);
  view.setScaleY(1);
  view.setCameraDistance(0);
}
 
Example 12
Source File: PagedView.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
@Override
public void screenScrolled(View v, int i, float scrollProgress) {
    float rotation = 90.0f * scrollProgress;

    v.setCameraDistance(mPagedView.mDensity * PagedView.CAMERA_DISTANCE);
    v.setTranslationX(v.getMeasuredWidth() * scrollProgress);
    v.setPivotX(!mPagedView.isLayoutRtl() ? 0f : v.getMeasuredWidth());
    v.setPivotY(v.getMeasuredHeight() / 2);
    v.setRotationY(-rotation);
}
 
Example 13
Source File: VerticalFlipTransformation.java    From Android-Image-Slider with Apache License 2.0 5 votes vote down vote up
@Override
public void transformPage(View page, float position) {

    page.setTranslationX(-position * page.getWidth());
    page.setCameraDistance(12000);

    if (position < 0.5 && position > -0.5) {
        page.setVisibility(View.VISIBLE);
    } else {
        page.setVisibility(View.INVISIBLE);
    }



    if (position < -1){     // [-Infinity,-1)
        // This page is way off-screen to the left.
        page.setAlpha(0);

    }
    else if (position <= 0) {    // [-1,0]
        page.setAlpha(1);
        page.setRotationY(180 *(1-Math.abs(position)+1));

    }
    else if (position <= 1) {    // (0,1]
        page.setAlpha(1);
        page.setRotationY(-180 *(1-Math.abs(position)+1));

    }
    else {    // (1,+Infinity]
        // This page is way off-screen to the right.
        page.setAlpha(0);

    }


}
 
Example 14
Source File: PagedView.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
@Override
public void screenScrolled(View v, int i, float scrollProgress) {
    float rotation = (mIn ? 90.0f : -90.0f) * scrollProgress;

    if (mIn) {
        v.setCameraDistance(mPagedView.mDensity * PagedView.CAMERA_DISTANCE);
    }

    v.setPivotX(scrollProgress < 0 ? 0 : v.getMeasuredWidth());
    v.setPivotY(v.getMeasuredHeight() * 0.5f);
    v.setRotationY(rotation);
}
 
Example 15
Source File: CubeInDepthTransformation.java    From Android-Image-Slider with Apache License 2.0 5 votes vote down vote up
@Override
public void transformPage(View page, float position) {
    page.setCameraDistance(20000);


    if (position < -1){
        page.setAlpha(0);
    }
    else if (position <= 0){
        page.setAlpha(1);
        page.setPivotX(page.getWidth());
        page.setRotationY(90*Math.abs(position));
    }
    else if (position <= 1){
        page.setAlpha(1);
        page.setPivotX(0);
        page.setRotationY(-90*Math.abs(position));
    }
    else{
        page.setAlpha(0);
    }



    if (Math.abs(position) <= 0.5){
        page.setScaleY(Math.max(.4f,1-Math.abs(position)));
    }
    else if (Math.abs(position) <= 1){
        page.setScaleY(Math.max(.4f,1-Math.abs(position)));

    }


}
 
Example 16
Source File: FlipPageViewTransformer.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
protected void onTransform(View view, float position) {
    float percentage = 1 - Math.abs(position);
    if(Build.VERSION.SDK_INT >= 13){
        view.setCameraDistance(12000);
    }
    setVisibility(view, position);
    setTranslation(view);
    setSize(view, position, percentage);
    setRotation(view, position, percentage);
}
 
Example 17
Source File: FlipPageViewTransformer.java    From AndroidImageSlider with MIT License 5 votes vote down vote up
@Override
protected void onTransform(View view, float position) {
    float percentage = 1 - Math.abs(position);
    if(Build.VERSION.SDK_INT >= 13){
        view.setCameraDistance(12000);
    }
    setVisibility(view, position);
    setTranslation(view);
    setSize(view, position, percentage);
    setRotation(view, position, percentage);
}
 
Example 18
Source File: CubeInRotationTransformation.java    From Android-Image-Slider with Apache License 2.0 5 votes vote down vote up
@Override
public void transformPage(View page, float position) {

    page.setCameraDistance(20000);


    if (position < -1){     // [-Infinity,-1)
        // This page is way off-screen to the left.
        page.setAlpha(0);

    }
    else if (position <= 0){    // [-1,0]
        page.setAlpha(1);
        page.setPivotX(page.getWidth());
        page.setRotationY(90*Math.abs(position));

    }
    else if (position <= 1){    // (0,1]
        page.setAlpha(1);
        page.setPivotX(0);
        page.setRotationY(-90*Math.abs(position));

    }
    else{    // (1,+Infinity]
        // This page is way off-screen to the right.
        page.setAlpha(0);

    }


}
 
Example 19
Source File: VerticalShutTransformation.java    From Android-Image-Slider with Apache License 2.0 5 votes vote down vote up
@Override
public void transformPage(View page, float position) {

    page.setTranslationX(-position*page.getWidth());
    page.setCameraDistance(999999999);

    if (position < 0.5 && position > -0.5){
        page.setVisibility(View.VISIBLE);
    }
    else {
        page.setVisibility(View.INVISIBLE);
    }



    if (position < -1){     // [-Infinity,-1)
        // This page is way off-screen to the left.
        page.setAlpha(0);

    }
    else if (position <= 0 ){    // [-1,0]
        page.setAlpha(1);
        page.setRotationX(180*(1-Math.abs(position)+1));

    }
    else if (position <= 1){    // (0,1]
        page.setAlpha(1);
        page.setRotationX(-180*(1-Math.abs(position)+1));

    }
    else {    // (1,+Infinity]
        // This page is way off-screen to the right.
        page.setAlpha(0);

    }


}
 
Example 20
Source File: AppsCustomizePagedView.java    From TurboLauncher with Apache License 2.0 4 votes vote down vote up
@Override
protected void screenScrolled(int screenCenter) {
    final boolean isRtl = isLayoutRtl();

    mUseTransitionEffect = !isInOverviewMode() && !mIsSwitchingState;

    updatePageAlphaValues(screenCenter);

    super.screenScrolled(screenCenter);

    enableHwLayersOnVisiblePages();

    boolean isInOverscroll = mOverScrollX < 0 || mOverScrollX > mMaxScrollX;

    if (isInOverscroll) {
        int index = 0;
        float pivotX = 0f;
        final float leftBiasedPivot = 0.35f;
        final float rightBiasedPivot = 0.65f;
        final int lowerIndex = 0;
        final int upperIndex = getChildCount() - 1;

        final boolean isLeftPage = mOverScrollX < 0;
        index = (!isRtl && isLeftPage) || (isRtl && !isLeftPage) ? lowerIndex : upperIndex;
        pivotX = isLeftPage ? rightBiasedPivot : leftBiasedPivot;

        View v = getPageAt(index);

        if (!mOverscrollTransformsSet || Float.compare(mLastOverscrollPivotX, pivotX) != 0) {
            mOverscrollTransformsSet = true;
            mLastOverscrollPivotX = pivotX;
            v.setCameraDistance(mDensity * mCameraDistance);
            v.setPivotX(v.getMeasuredWidth() * pivotX);
        }

        float scrollProgress = getScrollProgress(screenCenter, v, index);
        float rotation = -TRANSITION_MAX_ROTATION * scrollProgress;
        v.setRotationY(rotation);
    } else {
        if (mOverscrollTransformsSet) {
            mOverscrollTransformsSet = false;
            View v0 = getPageAt(mCurrentPage);
            v0.setRotationY(0);
            v0.setCameraDistance(mDensity * mCameraDistance);
            v0.setPivotX(v0.getMeasuredWidth() / 2);
            v0.setPivotY(v0.getMeasuredHeight() / 2);
        }
    }
}