Example usage for android.view View setScaleY

List of usage examples for android.view View setScaleY

Introduction

In this page you can find the example usage for android.view View setScaleY.

Prototype

public void setScaleY(float scaleY) 

Source Link

Document

Sets the amount that the view is scaled in Y around the pivot point, as a proportion of the view's unscaled width.

Usage

From source file:me.xiaopan.android.widget.DepthPageTransformer.java

@SuppressLint("NewApi")
@Override//  w w w.ja v a  2 s .c om
public void transformPage(View view, float position) {
    int pageWidth = view.getWidth();
    if (position < -1) { // [-Infinity,-1)
                         // This page is way off-screen to the left.
        view.setAlpha(0);
    } else if (position <= 0) { // [-1,0]
                                // Use the default slide transition when
                                // moving to the left page
        view.setAlpha(1);
        view.setTranslationX(0);
        view.setScaleX(1);
        view.setScaleY(1);
    } else if (position <= 1) { // (0,1]
                                // Fade the page out.
        view.setAlpha(1 - position);
        // Counteract the default slide transition
        view.setTranslationX(pageWidth * -position);
        // Scale the page down (between MIN_SCALE and 1)
        float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
        view.setScaleX(scaleFactor);
        view.setScaleY(scaleFactor);
    } else { // (1,+Infinity]
             // This page is way off-screen to the right.
        view.setAlpha(0);
    }
}

From source file:com.amaze.filemanager.utils.FlipAnim.java

public void transformPage(View view, float position) {
    int pageWidth = view.getWidth();
    if (position < -1) { // [-Infinity,-1)
        // This page is way off-screen to the left.
        view.setAlpha(0);/*w w  w  .  j  a v  a 2s .  c o m*/
    } else if (position <= 0) { // [-1,0]
        // Use the default slide transition when moving to the left page
        view.setAlpha(1);
        view.setTranslationY(0);
        //   view.setRotationX(Math.round(360*position));
        view.setRotationY(Math.round(360 * position));
        view.setScaleX(1 + position);
        view.setScaleY(1 + position);
    } else if (position <= 1) { // (0,1]
        // Fade the page out.
        view.setAlpha(1 - position);
        // Counteract the default slide transition
        view.setTranslationY(pageWidth * position * position);
        view.setTranslationX(pageWidth * position * position);
        //   view.setRotationX(Math.round(360*position));
        view.setRotationY(Math.round(360 * position));
        // Scale the page down (between MIN_SCALE and 1)

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

From source file:com.muller.snappingsample.SnappingRecyclerView.java

private void updateViews() {
    for (int i = 0; i < getChildCount(); i++) {
        View child = getChildAt(i);
        setMarginsForChild(child);/*w ww. j av a2 s . c o  m*/

        if (_scaleViews) {
            float percentage = getPercentageFromCenter(child);
            float scale = 1f - (0.7f * percentage);

            child.setScaleX(scale);
            child.setScaleY(scale);
        }
    }
}

From source file:com.lsjwzh.widget.recyclerviewpagerdeomo.VerticalLayoutFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final Activity activity = getActivity();

    mToast = Toast.makeText(activity, "", Toast.LENGTH_SHORT);
    mToast.setGravity(Gravity.CENTER, 0, 0);

    mRecyclerView = (RecyclerViewPager) view.findViewById(R.id.viewpager);

    LinearLayoutManager layout = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
    mRecyclerView.setTriggerOffset(0.15f);
    mRecyclerView.setFlingFactor(0.25f);
    mRecyclerView.setLayoutManager(layout);
    mRecyclerView.setAdapter(new LayoutAdapter(activity, mRecyclerView));
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLongClickable(true);

    mPositionText = (TextView) view.getRootView().findViewById(R.id.position);
    mCountText = (TextView) view.getRootView().findViewById(R.id.count);

    mStateText = (TextView) view.getRootView().findViewById(R.id.state);
    updateState(RecyclerView.SCROLL_STATE_IDLE);

    mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override//  w  ww  .  j a  va2  s.  c om
        public void onScrollStateChanged(RecyclerView recyclerView, int scrollState) {
            updateState(scrollState);
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int i, int i2) {
            //                mPositionText.setText("First: " + mRecyclerViewPager.getFirstVisiblePosition());
            int childCount = mRecyclerView.getChildCount();
            int width = mRecyclerView.getChildAt(0).getWidth();
            int padding = (mRecyclerView.getWidth() - width) / 2;
            mCountText.setText("Count: " + childCount);

            for (int j = 0; j < childCount; j++) {
                View v = recyclerView.getChildAt(j);
                //  padding  -(v.getWidth()-padding) ?
                float rate = 0;
                if (v.getLeft() <= padding) {
                    if (v.getLeft() >= padding - v.getWidth()) {
                        rate = (padding - v.getLeft()) * 1f / v.getWidth();
                    } else {
                        rate = 1;
                    }
                    v.setScaleY(1 - rate * 0.1f);
                } else {
                    //?  padding  recyclerView.getWidth()-padding ?
                    if (v.getLeft() <= recyclerView.getWidth() - padding) {
                        rate = (recyclerView.getWidth() - padding - v.getLeft()) * 1f / v.getWidth();
                    }
                    v.setScaleY(0.9f + rate * 0.1f);
                }
            }
        }
    });

    mRecyclerView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop,
                int oldRight, int oldBottom) {
            if (mRecyclerView.getChildCount() < 3) {
                if (mRecyclerView.getChildAt(1) != null) {
                    View v1 = mRecyclerView.getChildAt(1);
                    v1.setScaleY(0.9f);
                }
            } else {
                if (mRecyclerView.getChildAt(0) != null) {
                    View v0 = mRecyclerView.getChildAt(0);
                    v0.setScaleY(0.9f);
                }
                if (mRecyclerView.getChildAt(2) != null) {
                    View v2 = mRecyclerView.getChildAt(2);
                    v2.setScaleY(0.9f);
                }
            }

        }
    });
}

From source file:com.gabm.fancyplaces.ui.MainWindow.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    menu.clear();/*w w w.j  a  v a 2 s.c  o  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:com.hannesdorfmann.home.HomeActivity.java

private void popAnim(View v, int startDelay, int duration) {
    if (v != null) {
        v.setAlpha(0f);/*w  w  w  . j  ava2s . co  m*/
        v.setScaleX(0f);
        v.setScaleY(0f);

        v.animate().alpha(1f).scaleX(1f).scaleY(1f).setStartDelay(startDelay).setDuration(duration)
                .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.overshoot));
    }
}

From source file:edward.com.recyclerview.BaseItemAnimator.java

void reset(View v) {
    v.setAlpha(1);/*from w w w.  j  av a  2 s . c  om*/
    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.lsjwzh.widget.recyclerviewpagerdeomo.LayoutFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final Activity activity = getActivity();

    mToast = Toast.makeText(activity, "", Toast.LENGTH_SHORT);
    mToast.setGravity(Gravity.CENTER, 0, 0);

    mRecyclerView = (RecyclerViewPager) view.findViewById(R.id.list);

    LinearLayoutManagerEx layout = new LinearLayoutManagerEx(getActivity(), OrientationHelperEx.HORIZONTAL,
            false);//from w  w  w.j a  v  a 2s .  c  om
    //        layout.setReverseLayout(true);
    mRecyclerView.setLayoutManager(layout);
    mRecyclerView.setAdapter(new LayoutAdapter(activity, mRecyclerView, mLayoutId));
    mRecyclerView.setDisplayPadding(dip2px(getActivity(), 15));
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLongClickable(true);

    mPositionText = (TextView) view.getRootView().findViewById(R.id.position);
    mCountText = (TextView) view.getRootView().findViewById(R.id.count);

    mStateText = (TextView) view.getRootView().findViewById(R.id.state);
    updateState(SCROLL_STATE_IDLE);

    mRecyclerView.setOnScrollListener(new RecyclerViewEx.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerViewEx recyclerView, int scrollState) {
            updateState(scrollState);
        }

        @Override
        public void onScrolled(RecyclerViewEx recyclerView, int i, int i2) {
            //                mPositionText.setText("First: " + mRecyclerView.getFirstVisiblePosition());
            int childCount = mRecyclerView.getChildCount();
            int width = mRecyclerView.getChildAt(0).getWidth();
            int padding = (mRecyclerView.getWidth() - width) / 2;
            mCountText.setText("Count: " + childCount);

            for (int j = 0; j < childCount; j++) {
                View v = recyclerView.getChildAt(j);
                //  padding  -(v.getWidth()-padding) ?
                float rate = 0;
                if (v.getLeft() <= padding) {
                    if (v.getLeft() >= padding - v.getWidth()) {
                        rate = (padding - v.getLeft()) * 1f / v.getWidth();
                    } else {
                        rate = 1;
                    }
                    v.setScaleY(1 - rate * 0.1f);
                } else {
                    //?  padding  recyclerView.getWidth()-padding ?
                    if (v.getLeft() <= recyclerView.getWidth() - padding) {
                        rate = (recyclerView.getWidth() - padding - v.getLeft()) * 1f / v.getWidth();
                    }
                    v.setScaleY(0.9f + rate * 0.1f);
                }
            }
        }
    });

    mRecyclerView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop,
                int oldRight, int oldBottom) {
            if (mRecyclerView.getChildAt(1) != null) {
                View v2 = mRecyclerView.getChildAt(1);
                v2.setScaleY(0.9f);
                mRecyclerView.removeOnLayoutChangeListener(this);
            }
        }
    });
}

From source file:com.lsjwzh.widget.recyclerviewpagerdeomo.HorizontalLayoutFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final Activity activity = getActivity();

    mToast = Toast.makeText(activity, "", Toast.LENGTH_SHORT);
    mToast.setGravity(Gravity.CENTER, 0, 0);

    mRecyclerView = (RecyclerViewPager) view.findViewById(R.id.list);

    LinearLayoutManager layout = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
    mRecyclerView.setLayoutManager(layout);
    mRecyclerView.setAdapter(new LayoutAdapter(activity, mRecyclerView));
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLongClickable(true);

    mPositionText = (TextView) view.getRootView().findViewById(R.id.position);
    mCountText = (TextView) view.getRootView().findViewById(R.id.count);

    mStateText = (TextView) view.getRootView().findViewById(R.id.state);
    updateState(RecyclerView.SCROLL_STATE_IDLE);

    mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override/*  w  w  w  .  ja v  a  2  s  . c o  m*/
        public void onScrollStateChanged(RecyclerView recyclerView, int scrollState) {
            updateState(scrollState);
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int i, int i2) {
            //                mPositionText.setText("First: " + mRecyclerView.getFirstVisiblePosition());
            int childCount = mRecyclerView.getChildCount();
            int width = mRecyclerView.getChildAt(0).getWidth();
            int padding = (mRecyclerView.getWidth() - width) / 2;
            mCountText.setText("Count: " + childCount);

            for (int j = 0; j < childCount; j++) {
                View v = recyclerView.getChildAt(j);
                //  padding  -(v.getWidth()-padding) ?
                float rate = 0;
                ;
                if (v.getLeft() <= padding) {
                    if (v.getLeft() >= padding - v.getWidth()) {
                        rate = (padding - v.getLeft()) * 1f / v.getWidth();
                    } else {
                        rate = 1;
                    }
                    v.setScaleY(1 - rate * 0.1f);
                } else {
                    //?  padding  recyclerView.getWidth()-padding ?
                    if (v.getLeft() <= recyclerView.getWidth() - padding) {
                        rate = (recyclerView.getWidth() - padding - v.getLeft()) * 1f / v.getWidth();
                    }
                    v.setScaleY(0.9f + rate * 0.1f);
                }
            }
        }
    });

    mRecyclerView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop,
                int oldRight, int oldBottom) {
            if (mRecyclerView.getChildCount() < 3) {
                if (mRecyclerView.getChildAt(1) != null) {
                    View v1 = mRecyclerView.getChildAt(1);
                    v1.setScaleY(0.9f);
                }
            } else {
                if (mRecyclerView.getChildAt(0) != null) {
                    View v0 = mRecyclerView.getChildAt(0);
                    v0.setScaleY(0.9f);
                }
                if (mRecyclerView.getChildAt(2) != null) {
                    View v2 = mRecyclerView.getChildAt(2);
                    v2.setScaleY(0.9f);
                }
            }

        }
    });
}

From source file:net.dewep.intranetepitech.animation.ZoomOutPageTransformer.java

private void positionPositive(View view, float position) {
    // [-1,1]//from w ww. j a va  2s .  c  om
    // Modify the default slide transition to shrink the page as well
    int pageWidth = view.getWidth();
    int pageHeight = view.getHeight();
    float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
    float vertMargin = pageHeight * (1 - scaleFactor) / 2;
    float horzMargin = pageWidth * (1 - scaleFactor) / 2;
    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));
}