Java Code Examples for android.support.v4.view.ViewCompat#setPivotY()

The following examples show how to use android.support.v4.view.ViewCompat#setPivotY() . 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: BGABannerUtil.java    From KUtils-master with Apache License 2.0 6 votes vote down vote up
public static void resetPageTransformer(List<? extends View> views) {
    if (views == null) {
        return;
    }

    for (View view : views) {
        view.setVisibility(View.VISIBLE);
        ViewCompat.setAlpha(view, 1);
        ViewCompat.setPivotX(view, view.getMeasuredWidth() * 0.5f);
        ViewCompat.setPivotY(view, view.getMeasuredHeight() * 0.5f);
        ViewCompat.setTranslationX(view, 0);
        ViewCompat.setTranslationY(view, 0);
        ViewCompat.setScaleX(view, 1);
        ViewCompat.setScaleY(view, 1);
        ViewCompat.setRotationX(view, 0);
        ViewCompat.setRotationY(view, 0);
        ViewCompat.setRotation(view, 0);
    }
}
 
Example 2
Source File: CubeOutTransformer.java    From PageRecyclerView with Apache License 2.0 5 votes vote down vote up
@Override
protected void onTransform(View view, float position, boolean forwardDirection, int mOrientation) {
	if (mOrientation == OnPageDataListener.HORIZONTAL) {
		ViewCompat.setPivotX(view, position < 0f ? view.getWidth() : 0f);
		ViewCompat.setPivotY(view, view.getHeight() * 0.5f);
		ViewCompat.setRotationY(view, 90f * position);
	} else {
		ViewCompat.setPivotY(view, position < 0f ? view.getHeight() : 0f);
		ViewCompat.setPivotX(view, view.getWidth() * 0.5f);
		ViewCompat.setRotationX(view, -90f * position);
	}
}
 
Example 3
Source File: ZoomCenterPageTransformer.java    From KUtils with Apache License 2.0 5 votes vote down vote up
@Override
public void handleLeftPage(View view, float position) {
    ViewCompat.setTranslationX(view, -view.getWidth() * position);

    ViewCompat.setPivotX(view, view.getWidth() * 0.5f);
    ViewCompat.setPivotY(view, view.getHeight() * 0.5f);
    ViewCompat.setScaleX(view, 1 + position);
    ViewCompat.setScaleY(view, 1 + position);

    if (position < -0.95f) {
        ViewCompat.setAlpha(view, 0);
    } else {
        ViewCompat.setAlpha(view, 1);
    }
}
 
Example 4
Source File: RotateDownTransformer.java    From LoyalNativeSlider with MIT License 5 votes vote down vote up
@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;

	ViewCompat.setPivotX(view, width * 0.5f);
       ViewCompat.setPivotY(view,height);
       ViewCompat.setRotation(view,rotation);
}
 
Example 5
Source File: MiFliingLayout.java    From PullRefreshView with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean onScroll(float y) {
    View view = getPullable().getView();
    int heigth = view.getMeasuredHeight();
    if (y >= 0) {
        ViewCompat.setPivotY(view, 0);
        ViewCompat.setScaleY(view, (heigth + y) / heigth);
    } else {
        ViewCompat.setPivotY(view, heigth);
        ViewCompat.setScaleY(view, (heigth - y) / heigth);
    }
    return true;
}
 
Example 6
Source File: ZoomStackPageTransformer.java    From JD-Test with Apache License 2.0 5 votes vote down vote up
@Override
public void handleRightPage(View view, float position) {
    ViewCompat.setTranslationX(view, -view.getWidth() * position);

    ViewCompat.setPivotX(view, view.getWidth() * 0.5f);
    ViewCompat.setPivotY(view, view.getHeight() * 0.5f);
    ViewCompat.setScaleX(view, 1 + position);
    ViewCompat.setScaleY(view, 1 + position);

    if (position > 0.95f) {
        ViewCompat.setAlpha(view, 0);
    } else {
        ViewCompat.setAlpha(view, 1);
    }
}
 
Example 7
Source File: ScaleInTopAnimator.java    From RecyclerviewAnimators with Apache License 2.0 5 votes vote down vote up
@Override
    protected void preAnimateAddImpl(RecyclerView.ViewHolder holder) {
        // @TODO https://code.google.com/p/android/issues/detail?id=80863
        ViewCompat.setPivotY(holder.itemView, 0);
//        holder.itemView.setPivotY(0);
        ViewCompat.setScaleX(holder.itemView, 0);
        ViewCompat.setScaleY(holder.itemView, 0);
    }
 
Example 8
Source File: HeaderActivity.java    From PullRefreshView with Apache License 2.0 5 votes vote down vote up
private void onMove() {
    int oy = (int) flingLayout.getMoveP() - scrollGeter.getScrollY();
    if (oy > 0) {
        int imgHeaderHeigth = animHeader.getMeasuredHeight();
        float ph = 1 + (float) oy / (float) imgHeaderHeigth;
        ViewCompat.setPivotY(animHeader, 0);
        ViewCompat.setScaleX(animHeader, ph);
        ViewCompat.setScaleY(animHeader, ph);

    } else {
        ViewCompat.setScaleX(animHeader, 1);
        ViewCompat.setScaleY(animHeader, 1);
        ViewCompat.setTranslationY(animHeader, oy);
    }
}
 
Example 9
Source File: ViewHelper.java    From SimpleNews with Apache License 2.0 5 votes vote down vote up
public static void clear(View v) {
  ViewCompat.setAlpha(v, 1);
  ViewCompat.setScaleY(v, 1);
  ViewCompat.setScaleX(v, 1);
  ViewCompat.setTranslationY(v, 0);
  ViewCompat.setTranslationX(v, 0);
  ViewCompat.setRotation(v, 0);
  ViewCompat.setRotationY(v, 0);
  ViewCompat.setRotationX(v, 0);
  ViewCompat.setPivotY(v, v.getMeasuredHeight() / 2);
  ViewCompat.setPivotX(v, v.getMeasuredWidth() / 2);
  ViewCompat.animate(v).setInterpolator(null).setStartDelay(0);
}
 
Example 10
Source File: ZoomFadePageTransformer.java    From KUtils with Apache License 2.0 5 votes vote down vote up
@Override
public void handleLeftPage(View view, float position) {
    ViewCompat.setTranslationX(view, -view.getWidth() * position);

    ViewCompat.setPivotX(view, view.getWidth() * 0.5f);
    ViewCompat.setPivotY(view, view.getHeight() * 0.5f);
    ViewCompat.setScaleX(view, 1 + position);
    ViewCompat.setScaleY(view, 1 + position);

    ViewCompat.setAlpha(view, 1 + position);
}
 
Example 11
Source File: ForegroundToBackgroundTransformer.java    From LoyalNativeSlider with MIT License 5 votes vote down vote up
@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);

	ViewCompat.setScaleX(view, scale);
       ViewCompat.setScaleY(view,scale);
       ViewCompat.setPivotX(view,width * 0.5f);
       ViewCompat.setPivotY(view,height * 0.5f);
       ViewCompat.setTranslationX(view,position > 0 ? width * position : -width * position * 0.25f);
}
 
Example 12
Source File: ZoomFadePageTransformer.java    From KUtils with Apache License 2.0 5 votes vote down vote up
@Override
public void handleRightPage(View view, float position) {
    ViewCompat.setTranslationX(view, -view.getWidth() * position);

    ViewCompat.setPivotX(view, view.getWidth() * 0.5f);
    ViewCompat.setPivotY(view, view.getHeight() * 0.5f);
    ViewCompat.setScaleX(view, 1 - position);
    ViewCompat.setScaleY(view, 1 - position);
    ViewCompat.setAlpha(view, 1 - position);
}
 
Example 13
Source File: ZoomCenterPageTransformer.java    From JD-Test with Apache License 2.0 5 votes vote down vote up
@Override
public void handleLeftPage(View view, float position) {
    ViewCompat.setTranslationX(view, -view.getWidth() * position);

    ViewCompat.setPivotX(view, view.getWidth() * 0.5f);
    ViewCompat.setPivotY(view, view.getHeight() * 0.5f);
    ViewCompat.setScaleX(view, 1 + position);
    ViewCompat.setScaleY(view, 1 + position);

    if (position < -0.95f) {
        ViewCompat.setAlpha(view, 0);
    } else {
        ViewCompat.setAlpha(view, 1);
    }
}
 
Example 14
Source File: CubeInTransformer.java    From LoyalNativeSlider with MIT License 5 votes vote down vote up
@Override
protected void onTransform(View view, float position) {
	// Rotate the fragment on the left or right edge
       ViewCompat.setPivotX(view,position > 0 ? 0 : view.getWidth());
       ViewCompat.setPivotY(view,0);
       ViewCompat.setRotation(view, -90f * position);
}
 
Example 15
Source File: BackgroundToForegroundTransformer.java    From LoyalNativeSlider with MIT License 5 votes vote down vote up
@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);

       ViewCompat.setScaleX(view, scale);
       ViewCompat.setScaleY(view,scale);
       ViewCompat.setPivotX(view,width*0.5f);
       ViewCompat.setPivotY(view,height*0.5f);
       ViewCompat.setTranslationX(view,position < 0 ? width * position : -width * position * 0.25f);
}
 
Example 16
Source File: ZoomStackPageTransformer.java    From KUtils-master with Apache License 2.0 5 votes vote down vote up
@Override
public void handleRightPage(View view, float position) {
    ViewCompat.setTranslationX(view, -view.getWidth() * position);

    ViewCompat.setPivotX(view, view.getWidth() * 0.5f);
    ViewCompat.setPivotY(view, view.getHeight() * 0.5f);
    ViewCompat.setScaleX(view, 1 + position);
    ViewCompat.setScaleY(view, 1 + position);

    if (position > 0.95f) {
        ViewCompat.setAlpha(view, 0);
    } else {
        ViewCompat.setAlpha(view, 1);
    }
}
 
Example 17
Source File: CubePageTransformer.java    From JD-Test with Apache License 2.0 4 votes vote down vote up
@Override
public void handleRightPage(View view, float position) {
    ViewCompat.setPivotX(view, 0);
    ViewCompat.setPivotY(view, view.getMeasuredHeight() * 0.5f);
    ViewCompat.setRotationY(view, mMaxRotation * position);
}
 
Example 18
Source File: MaterialTextField.java    From MaterialTextField with Apache License 2.0 4 votes vote down vote up
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    editText = findEditTextChild();
    if (editText == null) {
        return;
    }

    addView(LayoutInflater.from(getContext()).inflate(R.layout.mtf_layout, this, false));

    editTextLayout = (ViewGroup) findViewById(R.id.mtf_editTextLayout);
    removeView(editText);
    editTextLayout.addView(editText);

    label = (TextView) findViewById(R.id.mtf_label);
    ViewCompat.setPivotX(label, 0);
    ViewCompat.setPivotY(label, 0);

    if (editText.getHint() != null) {
        label.setText(editText.getHint());
        editText.setHint("");
    }

    card = findViewById(R.id.mtf_card);

    if (backgroundColor != -1) {
        card.setBackgroundColor(backgroundColor);
    }

    final int expandedHeight = getContext().getResources().getDimensionPixelOffset(R.dimen.mtf_cardHeight_final);
    final int reducedHeight = cardCollapsedHeight;

    reducedScale = (float) (reducedHeight * 1.0 / expandedHeight);
    ViewCompat.setScaleY(card, reducedScale);
    ViewCompat.setPivotY(card, expandedHeight);

    image = (ImageView) findViewById(R.id.mtf_image);
    ViewCompat.setAlpha(image, 0);
    ViewCompat.setScaleX(image, 0.4f);
    ViewCompat.setScaleY(image, 0.4f);

    ViewCompat.setAlpha(editText, 0f);
    editText.setBackgroundColor(Color.TRANSPARENT);

    labelTopMargin = FrameLayout.LayoutParams.class.cast(label.getLayoutParams()).topMargin;

    customizeFromAttributes();

    this.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            toggle();
        }
    });

    setHasFocus(hasFocus);
}
 
Example 19
Source File: CubePageTransformer.java    From KUtils with Apache License 2.0 4 votes vote down vote up
@Override
public void handleInvisiblePage(View view, float position) {
    ViewCompat.setPivotX(view, view.getMeasuredWidth());
    ViewCompat.setPivotY(view, view.getMeasuredHeight() * 0.5f);
    ViewCompat.setRotationY(view, 0);
}
 
Example 20
Source File: FloatLabelLayout.java    From 365browser with Apache License 2.0 4 votes vote down vote up
public FloatLabelLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setOrientation(VERTICAL);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatLabelLayout);

    int leftPadding = a.getDimensionPixelSize(
            R.styleable.FloatLabelLayout_floatLabelPaddingLeft,
            dipsToPix(DEFAULT_LABEL_PADDING_LEFT));
    int topPadding = a.getDimensionPixelSize(
            R.styleable.FloatLabelLayout_floatLabelPaddingTop,
            dipsToPix(DEFAULT_LABEL_PADDING_TOP));
    int rightPadding = a.getDimensionPixelSize(
            R.styleable.FloatLabelLayout_floatLabelPaddingRight,
            dipsToPix(DEFAULT_LABEL_PADDING_RIGHT));
    int bottomPadding = a.getDimensionPixelSize(
            R.styleable.FloatLabelLayout_floatLabelPaddingBottom,
            dipsToPix(DEFAULT_LABEL_PADDING_BOTTOM));
    mHint = a.getText(R.styleable.FloatLabelLayout_floatLabelHint);

    mLabel = new TextView(context);
    mLabel.setPadding(leftPadding, topPadding, rightPadding, bottomPadding);
    mLabel.setVisibility(INVISIBLE);
    mLabel.setText(mHint);
    mLabel.setFocusable(true);
    ViewCompat.setPivotX(mLabel, 0f);
    ViewCompat.setPivotY(mLabel, 0f);

    ApiCompatibilityUtils.setTextAppearance(mLabel,
            a.getResourceId(R.styleable.FloatLabelLayout_floatLabelTextAppearance,
                    android.R.style.TextAppearance_Small));
    a.recycle();

    addView(mLabel, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    mInterpolator = AnimationUtils.loadInterpolator(context,
            Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
                ? android.R.interpolator.fast_out_slow_in
                : android.R.anim.decelerate_interpolator);
}