com.nineoldandroids.view.ViewHelper Java Examples

The following examples show how to use com.nineoldandroids.view.ViewHelper. 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: AccordionTransformer.java    From Social with Apache License 2.0 6 votes vote down vote up
@Override
public void transformPage(View view, float position) {
	if (position < -1) {
		ViewHelper.setPivotX(view, view.getMeasuredWidth() * 0.5f);
		ViewHelper.setPivotY(view, view.getMeasuredHeight() * 0.5f);
		ViewHelper.setScaleX(view, 1);
	} else if (position <= 0) {
		ViewHelper.setPivotX(view, view.getMeasuredWidth());
		ViewHelper.setPivotY(view, 0);
		ViewHelper.setScaleX(view, 1 + position);
	} else if (position <= 1) {
		ViewHelper.setPivotX(view, 0);
		ViewHelper.setPivotY(view, 0);
		ViewHelper.setScaleX(view, 1 - position);
	} else {
		ViewHelper.setPivotX(view, view.getMeasuredWidth() * 0.5f);
		ViewHelper.setPivotY(view, view.getMeasuredHeight() * 0.5f);
		ViewHelper.setScaleX(view, 1);
	}
}
 
Example #2
Source File: FloatingActionButton.java    From Fabulous with MIT License 6 votes vote down vote up
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    // Perform the default behavior
    super.onLayout(changed, left, top, right, bottom);
    if (mLeftDisplayed == -1) {
        mLeftDisplayed = left;
        mRightDisplayed = right;
        mTopDisplayed = top;
        mBottomDisplayed = bottom;
    }

    // Store the FAB button's displayed Y position if we are not already aware of it
    if (mYDisplayed == -1) {
        mYDisplayed = ViewHelper.getY(this);
    }
}
 
Example #3
Source File: FlexibleSpaceToolbarWebViewActivity.java    From Android-ObservableScrollView with Apache License 2.0 6 votes vote down vote up
private void updateFlexibleSpaceText(final int scrollY) {
    ViewHelper.setTranslationY(mFlexibleSpaceView, -scrollY);
    int adjustedScrollY = (int) ScrollUtils.getFloat(scrollY, 0, mFlexibleSpaceHeight);

    // Special logic for WebView.
    adjustTopMargin(mWebViewContainer, adjustedScrollY <= mFlexibleSpaceHeight ? 0 : mFlexibleSpaceHeight + getActionBarSize());

    float maxScale = (float) (mFlexibleSpaceHeight - mToolbarView.getHeight()) / mToolbarView.getHeight();
    float scale = maxScale * ((float) mFlexibleSpaceHeight - adjustedScrollY) / mFlexibleSpaceHeight;

    ViewHelper.setPivotX(mTitleView, 0);
    ViewHelper.setPivotY(mTitleView, 0);
    ViewHelper.setScaleX(mTitleView, 1 + scale);
    ViewHelper.setScaleY(mTitleView, 1 + scale);
    int maxTitleTranslationY = mToolbarView.getHeight() + mFlexibleSpaceHeight - (int) (mTitleView.getHeight() * (1 + scale));
    int titleTranslationY = (int) (maxTitleTranslationY * ((float) mFlexibleSpaceHeight - adjustedScrollY) / mFlexibleSpaceHeight);
    ViewHelper.setTranslationY(mTitleView, titleTranslationY);
}
 
Example #4
Source File: ToolbarControlRecyclerViewActivity.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
@Override
public void onUpOrCancelMotionEvent(ScrollState scrollState) {
    mBaseTranslationY = 0;

    float headerTranslationY = ViewHelper.getTranslationY(mHeaderView);
    int toolbarHeight = mToolbarView.getHeight();
    if (scrollState == ScrollState.UP) {
        if (toolbarHeight < mRecyclerView.getCurrentScrollY()) {
            if (headerTranslationY != -toolbarHeight) {
                ViewPropertyAnimator.animate(mHeaderView).cancel();
                ViewPropertyAnimator.animate(mHeaderView).translationY(-toolbarHeight).setDuration(200).start();
            }
        }
    } else if (scrollState == ScrollState.DOWN) {
        if (toolbarHeight < mRecyclerView.getCurrentScrollY()) {
            if (headerTranslationY != 0) {
                ViewPropertyAnimator.animate(mHeaderView).cancel();
                ViewPropertyAnimator.animate(mHeaderView).translationY(0).setDuration(200).start();
            }
        }
    }
}
 
Example #5
Source File: ResideMenu.java    From Libraries-for-Android-Developers with MIT License 6 votes vote down vote up
/**
 * a helper method to build scale down animation;
 *
 * @param target
 * @param targetScaleX
 * @param targetScaleY
 * @return
 */
private AnimatorSet buildScaleDownAnimation(View target,float targetScaleX,float targetScaleY){

    // set the pivotX and pivotY to scale;
    int pivotX = (int) (getScreenWidth()  * 1.5);
    int pivotY = (int) (getScreenHeight() * 0.5);

    ViewHelper.setPivotX(target, pivotX);
    ViewHelper.setPivotY(target, pivotY);
    AnimatorSet scaleDown = new AnimatorSet();
    scaleDown.playTogether(
            ObjectAnimator.ofFloat(target, "scaleX", targetScaleX),
            ObjectAnimator.ofFloat(target, "scaleY", targetScaleY)
    );

    scaleDown.setInterpolator(AnimationUtils.loadInterpolator(activity,
            android.R.anim.decelerate_interpolator));
    scaleDown.setDuration(250);
    return scaleDown;
}
 
Example #6
Source File: ToolbarControlBaseActivity.java    From Android-ObservableScrollView with Apache License 2.0 6 votes vote down vote up
private void moveToolbar(float toTranslationY) {
    if (ViewHelper.getTranslationY(mToolbar) == toTranslationY) {
        return;
    }
    ValueAnimator animator = ValueAnimator.ofFloat(ViewHelper.getTranslationY(mToolbar), toTranslationY).setDuration(200);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float translationY = (float) animation.getAnimatedValue();
            ViewHelper.setTranslationY(mToolbar, translationY);
            ViewHelper.setTranslationY((View) mScrollable, translationY);
            FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) ((View) mScrollable).getLayoutParams();
            lp.height = (int) -translationY + getScreenHeight() - lp.topMargin;
            ((View) mScrollable).requestLayout();
        }
    });
    animator.start();
}
 
Example #7
Source File: MainActivity.java    From DMusic with Apache License 2.0 6 votes vote down vote up
private void initMenu() {
    fManger = new FManger(dlDrawer, getSupportFragmentManager());
    fManger.replace(new MainFragment());
    dlDrawer.setScrimColor(getResources().getColor(R.color.lib_pub_color_trans));
    dlDrawer.addDrawerListener(new DrawerLayout.SimpleDrawerListener() {
        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            View content = dlDrawer.getChildAt(0);
            float scale = 1 - slideOffset;
            float rightScale = 0.8f + scale * 0.2f;
            float leftScale = 1 - 0.3f * scale;

            ViewHelper.setScaleX(drawerView, leftScale);
            ViewHelper.setScaleY(drawerView, leftScale);

            ViewHelper.setTranslationX(content, -drawerView.getMeasuredWidth() * slideOffset);
            ViewHelper.setPivotX(content, content.getMeasuredWidth());
            ViewHelper.setPivotY(content, content.getMeasuredHeight() / 2);
            content.invalidate();
            ViewHelper.setScaleX(content, rightScale);
            ViewHelper.setScaleY(content, rightScale);
        }
    });
}
 
Example #8
Source File: ToolbarControlWebViewActivity.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
@Override
public void onUpOrCancelMotionEvent(ScrollState scrollState) {
    mDragging = false;
    mBaseTranslationY = 0;

    float headerTranslationY = ViewHelper.getTranslationY(mHeaderView);
    int toolbarHeight = mToolbarView.getHeight();
    if (scrollState == ScrollState.UP) {
        if (toolbarHeight < mScrollView.getCurrentScrollY()) {
            if (headerTranslationY != -toolbarHeight) {
                ViewPropertyAnimator.animate(mHeaderView).cancel();
                ViewPropertyAnimator.animate(mHeaderView).translationY(-toolbarHeight).setDuration(200).start();
            }
        }
    } else if (scrollState == ScrollState.DOWN) {
        if (toolbarHeight < mScrollView.getCurrentScrollY()) {
            if (headerTranslationY != 0) {
                ViewPropertyAnimator.animate(mHeaderView).cancel();
                ViewPropertyAnimator.animate(mHeaderView).translationY(0).setDuration(200).start();
            }
        }
    }
}
 
Example #9
Source File: Delegate.java    From AndroidSweetSheet with Apache License 2.0 6 votes vote down vote up
/**
 * 显示模糊背景
 */
protected void showShowdown() {

    ViewHelper.setTranslationY(mRootView, 0);
    mEffect.effect(mParentVG,mBg);
    ViewGroup.LayoutParams lp =
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    if(mBg.getParent()!= null){
        mParentVG.removeView(mBg);
    }

    mParentVG.addView(mBg, lp);
    ViewHelper.setAlpha(mBg, 0);
    ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(mBg, "alpha", 0, 1);
    objectAnimator.setDuration(400);
    objectAnimator.start();
}
 
Example #10
Source File: JazzyViewPager.java    From android-kernel-tweaker with GNU General Public License v3.0 6 votes vote down vote up
private void animateZoom(View left, View right, float positionOffset, boolean in) {
	if (mState != State.IDLE) {
		if (left != null) {
			manageLayer(left, true);
			mScale = in ? ZOOM_MAX + (1-ZOOM_MAX)*(1-positionOffset) :
				1+ZOOM_MAX - ZOOM_MAX*(1-positionOffset);
			ViewHelper.setPivotX(left, left.getMeasuredWidth()*0.5f);
			ViewHelper.setPivotY(left, left.getMeasuredHeight()*0.5f);
			ViewHelper.setScaleX(left, mScale);
			ViewHelper.setScaleY(left, mScale);
		}
		if (right != null) {
			manageLayer(right, true);
			mScale = in ? ZOOM_MAX + (1-ZOOM_MAX)*positionOffset :
				1+ZOOM_MAX - ZOOM_MAX*positionOffset;
			ViewHelper.setPivotX(right, right.getMeasuredWidth()*0.5f);
			ViewHelper.setPivotY(right, right.getMeasuredHeight()*0.5f);
			ViewHelper.setScaleX(right, mScale);
			ViewHelper.setScaleY(right, mScale);
		}
	}
}
 
Example #11
Source File: ToolbarControlScrollViewActivity.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
@Override
public void onUpOrCancelMotionEvent(ScrollState scrollState) {
    mBaseTranslationY = 0;

    float headerTranslationY = ViewHelper.getTranslationY(mHeaderView);
    int toolbarHeight = mToolbarView.getHeight();
    if (scrollState == ScrollState.UP) {
        if (toolbarHeight < mScrollView.getCurrentScrollY()) {
            if (headerTranslationY != -toolbarHeight) {
                ViewPropertyAnimator.animate(mHeaderView).cancel();
                ViewPropertyAnimator.animate(mHeaderView).translationY(-toolbarHeight).setDuration(200).start();
            }
        }
    } else if (scrollState == ScrollState.DOWN) {
        if (toolbarHeight < mScrollView.getCurrentScrollY()) {
            if (headerTranslationY != 0) {
                ViewPropertyAnimator.animate(mHeaderView).cancel();
                ViewPropertyAnimator.animate(mHeaderView).translationY(0).setDuration(200).start();
            }
        }
    }
}
 
Example #12
Source File: PullToNextView.java    From Android-PullToNextLayout with Apache License 2.0 6 votes vote down vote up
public void reset(BaseAdapter adapter, int position) {
    setHeaderTopMargin(-mHeadViewHeight);
    initContentView(adapter, position);
    mScrollView=null;
    mWebView=null;
    ViewHelper.setAlpha(this, 1);
    ViewHelper.setTranslationY(this, 0);
    ViewHelper.setTranslationY(this, 0);
    ViewHelper.setScaleX(this, 1);
    ViewHelper.setScaleY(this, 1);
    ViewHelper.setScrollX(this, 0);
    ViewHelper.setScrollY(this, 0);
    ViewHelper.setRotationX(this, 0);
    ViewHelper.setRotationY(this, 0);


}
 
Example #13
Source File: LoadToast.java    From RxAndroidBootstrap with Apache License 2.0 6 votes vote down vote up
public LoadToast(Context context){
    mView = new LoadToastView(context);
    mParentView = (ViewGroup) ((Activity) context).getWindow().getDecorView().findViewById(android.R.id.content);
    mParentView.addView(mView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    ViewHelper.setAlpha(mView, 0);
    mParentView.postDelayed(new Runnable() {
        @Override
        public void run() {
            ViewHelper.setTranslationX(mView, (mParentView.getWidth() - mView.getWidth()) / 2);
            ViewHelper.setTranslationY(mView, -mView.getHeight() + mTranslationY);
            mInflated = true;
            if(mShowCalled) show();
        }
    },1);

    mParentView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            checkZPosition();
        }
    });
}
 
Example #14
Source File: JazzyViewPager.java    From android-kernel-tweaker with GNU General Public License v3.0 6 votes vote down vote up
private void animateRotate(View left, View right, float positionOffset, boolean up) {
	if (mState != State.IDLE) {
		if (left != null) {
			manageLayer(left, true);
			mRot = (up ? 1 : -1) * (ROT_MAX * positionOffset);
			mTrans = (up ? -1 : 1) * (float) (getMeasuredHeight() - getMeasuredHeight()*Math.cos(mRot*Math.PI/180.0f));
			ViewHelper.setPivotX(left, left.getMeasuredWidth()*0.5f);
			ViewHelper.setPivotY(left, up ? 0 : left.getMeasuredHeight());
			ViewHelper.setTranslationY(left, mTrans);
			ViewHelper.setRotation(left, mRot);
		}
		if (right != null) {
			manageLayer(right, true);
			mRot = (up ? 1 : -1) * (-ROT_MAX + ROT_MAX*positionOffset);
			mTrans = (up ? -1 : 1) * (float) (getMeasuredHeight() - getMeasuredHeight()*Math.cos(mRot*Math.PI/180.0f));
			ViewHelper.setPivotX(right, right.getMeasuredWidth()*0.5f);
			ViewHelper.setPivotY(right, up ? 0 : right.getMeasuredHeight());
			ViewHelper.setTranslationY(right, mTrans);
			ViewHelper.setRotation(right, mRot);
		}
	}
}
 
Example #15
Source File: AnimationAdapter.java    From ALLGO with Apache License 2.0 6 votes vote down vote up
private void animateView(int position, ViewGroup parent, View view) {
	if (mAnimationStartMillis == -1) {
		mAnimationStartMillis = System.currentTimeMillis();
	}

	ViewHelper.setAlpha(view, 0);

	Animator[] childAnimators;
	if (mDecoratedBaseAdapter instanceof AnimationAdapter) {
		childAnimators = ((AnimationAdapter) mDecoratedBaseAdapter).getAnimators(parent, view);
	} else {
		childAnimators = new Animator[0];
	}
	Animator[] animators = getAnimators(parent, view);
	Animator alphaAnimator = ObjectAnimator.ofFloat(view, "alpha", 0, 1);

	AnimatorSet set = new AnimatorSet();
	set.playTogether(concatAnimators(childAnimators, animators, alphaAnimator));
	set.setStartDelay(calculateAnimationDelay());
	set.setDuration(getAnimationDurationMillis());
	set.start();

	mAnimators.put(view.hashCode(), set);
}
 
Example #16
Source File: MotionEventUtils.java    From ListViewAnimations with Apache License 2.0 6 votes vote down vote up
public static List<MotionEvent> createMotionEvents(final AbsListView absListView, final int position, final float fromX, final float toX) {
    int[] listViewCoords = new int[2];
    absListView.getLocationOnScreen(listViewCoords);

    View view = absListView.getChildAt(position - absListView.getFirstVisiblePosition());
    int y = (int) (ViewHelper.getY(view) + view.getHeight() / 2) + listViewCoords[1];

    List<MotionEvent> results = new ArrayList<>();
    results.add(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, fromX, y, 0));

    float diff = fromX - toX;
    for (int i = 1; i < 10; i++) {
        float x = fromX + diff / 10 * i;
        results.add(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_MOVE, x, y, 0));
    }
    results.add(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, toX, y, 0));

    return results;
}
 
Example #17
Source File: FlycoPageIndicaor.java    From FlycoPageIndicator with MIT License 6 votes vote down vote up
@Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        if (!isSnap) {
            /**
             * position:当前View的位置
             * positionOffset:当前View的偏移量比例.[0,1)
             */
            this.currentItem = position;

            float tranlationX = (indicatorWidth + indicatorGap) * (currentItem + positionOffset);
            ViewHelper.setTranslationX(selectView, tranlationX);

//            RelativeLayout.LayoutParams lp = new  RelativeLayout.LayoutParams(indicatorWidth,
//                    indicatorHeight);
//            lp.leftMargin = (int) tranlationX;
//            selectView.setLayoutParams(lp);
        }
    }
 
Example #18
Source File: JazzyViewPager.java    From ClockView with Apache License 2.0 6 votes vote down vote up
private void animateCubeOut(View left, View right, float positionOffset)
	{
		if (mState != State.IDLE)
		{
			if (left != null)
			{
				manageLayer(left, true);
				mRot =  -70.0f * positionOffset;
				ViewHelper.setPivotX(left, left.getMeasuredWidth());
				ViewHelper.setPivotY(left, left.getMeasuredHeight() * 0.5f);
//				ViewHelper.setScaleX(left,1 - positionOffset);
//				ViewHelper.setScaleY(left,1 - positionOffset);
				ViewHelper.setRotationY(left, mRot);
			}
			if (right != null)
			{
				manageLayer(right, true);
				mRot = 70.0f * (1 - positionOffset);
				ViewHelper.setPivotX(right, 0);
				ViewHelper.setPivotY(right, right.getMeasuredHeight() * 0.5f);
//				ViewHelper.setScaleX(right,positionOffset);
//				ViewHelper.setScaleY(right,positionOffset);
				ViewHelper.setRotationY(right, mRot);
			}
		}
	}
 
Example #19
Source File: UndoBarController.java    From example with Apache License 2.0 6 votes vote down vote up
public void showUndoBar(boolean immediate, CharSequence message, Parcelable undoToken) {

        mUndoToken = undoToken;
        mUndoMessage = message;
        mMessageView.setText(mUndoMessage);

        mHideHandler.removeCallbacks(mHideRunnable);
        mHideHandler.postDelayed(mHideRunnable,
                mBarView.getResources().getInteger(R.integer.list_card_undobar_hide_delay));

        mBarView.setVisibility(View.VISIBLE);
        if (immediate) {
            ViewHelper.setAlpha(mBarView, 1);
        } else {
            mBarAnimator.cancel();
            mBarAnimator
                    .alpha(1)
                    .setDuration(
                            mBarView.getResources()
                                    .getInteger(android.R.integer.config_shortAnimTime))
                    .setListener(null);
        }
    }
 
Example #20
Source File: JazzyViewPager.java    From ClockView with Apache License 2.0 5 votes vote down vote up
private void logState(View v, String title)
{
	Log.v(TAG,
			title + ": ROT (" + ViewHelper.getRotation(v) + ", "
					+ ViewHelper.getRotationX(v) + ", "
					+ ViewHelper.getRotationY(v) + "), TRANS ("
					+ ViewHelper.getTranslationX(v) + ", "
					+ ViewHelper.getTranslationY(v) + "), SCALE ("
					+ ViewHelper.getScaleX(v) + ", "
					+ ViewHelper.getScaleY(v) + "), ALPHA "
					+ ViewHelper.getAlpha(v));
}
 
Example #21
Source File: FillGap2ListViewActivity.java    From Android-ObservableScrollView with Apache License 2.0 5 votes vote down vote up
@Override
protected void updateViews(int scrollY, boolean animated) {
    super.updateViews(scrollY, animated);

    // Translate list background
    ViewHelper.setTranslationY(mListBackgroundView, ViewHelper.getTranslationY(mHeader));
}
 
Example #22
Source File: ThumbnailsAdapter.java    From AndroidPhotoFilters with Apache License 2.0 5 votes vote down vote up
private void setAnimation(View viewToAnimate, int position) {
    {
        ViewHelper.setAlpha(viewToAnimate, .0f);
        com.nineoldandroids.view.ViewPropertyAnimator.animate(viewToAnimate).alpha(1).setDuration(250).start();
        lastPosition = position;
    }
}
 
Example #23
Source File: RotateDownTransformer.java    From ImageSliderWithSwipes with Apache License 2.0 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;

	ViewHelper.setPivotX(view,width * 0.5f);
       ViewHelper.setPivotY(view,height);
       ViewHelper.setRotation(view,rotation);
}
 
Example #24
Source File: JazzyViewPager.java    From Contacts with MIT License 5 votes vote down vote up
private void animateFlipVertical(View left, View right, float positionOffset, int positionOffsetPixels) {
	if(mState != State.IDLE) {
		if (left != null) {
			manageLayer(left, true);
			mRot = 180.0f * positionOffset;
			if (mRot > 90.0f) {
				left.setVisibility(View.INVISIBLE);
			} else {
				if (left.getVisibility() == View.INVISIBLE)
					left.setVisibility(View.VISIBLE);
				mTrans = positionOffsetPixels;
				ViewHelper.setPivotX(left, left.getMeasuredWidth()*0.5f);
				ViewHelper.setPivotY(left, left.getMeasuredHeight()*0.5f);
				ViewHelper.setTranslationX(left, mTrans);
				ViewHelper.setRotationX(left, mRot);
			}
		}
		if (right != null) {
			manageLayer(right, true);
			mRot = -180.0f * (1-positionOffset);
			if (mRot < -90.0f) {
				right.setVisibility(View.INVISIBLE);
			} else {
				if (right.getVisibility() == View.INVISIBLE)
					right.setVisibility(View.VISIBLE);
				mTrans = -getWidth()-getPageMargin()+positionOffsetPixels;
				ViewHelper.setPivotX(right, right.getMeasuredWidth()*0.5f);
				ViewHelper.setPivotY(right, right.getMeasuredHeight()*0.5f);
				ViewHelper.setTranslationX(right, mTrans);
				ViewHelper.setRotationX(right, mRot);
			}
		}
	}
}
 
Example #25
Source File: CardsEffect.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void initView(View view, int i, int j)
{
    ViewHelper.setPivotX(view, view.getWidth() / 2);
    ViewHelper.setPivotY(view, view.getHeight() / 2);
    ViewHelper.setRotationX(view, j * 90);
    ViewHelper.setTranslationY(view, j * view.getHeight());
}
 
Example #26
Source File: PullPushLayout.java    From Android-PullPushScrollView with MIT License 5 votes vote down vote up
private float animateScroll(int t) {
    float percent = (float) t / range;
    if(percent > 1){
    	percent = 1;
    }
    ViewHelper.setTranslationY(mHeader, t);
    
    return percent;
   
}
 
Example #27
Source File: JazzyViewPager.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
protected void animateStack(View left, View right, float positionOffset, int positionOffsetPixels) {
    if (mState != State.IDLE) {
        if (right != null) {
            manageLayer(right, true);
            mScale = (1 - SCALE_MAX) * positionOffset + SCALE_MAX;
            mTrans = -getWidth() - getPageMargin() + positionOffsetPixels;
            ViewHelper.setScaleX(right, mScale);
            ViewHelper.setScaleY(right, mScale);
            ViewHelper.setTranslationX(right, mTrans);
        }
        if (left != null) {
            left.bringToFront();
        }
    }
}
 
Example #28
Source File: CardView.java    From CardView with MIT License 5 votes vote down vote up
private void ensureFull() {
	while (mNextAdapterPosition < mListAdapter.getCount()
			&& getChildCount() < mMaxVisible) {
		int index = mNextAdapterPosition % mMaxVisible;
		View convertView = viewHolder.get(index);
		final View view = mListAdapter.getView(mNextAdapterPosition,
				convertView, this);
		view.setOnClickListener(null);
		viewHolder.put(index, view);

		// 添加剩余的View时,始终处在最后
		index = Math.min(mNextAdapterPosition, mMaxVisible - 1);
		ViewHelper.setScaleX(view,((mMaxVisible - index - 1) / (float) mMaxVisible) * 0.2f + 0.8f);
		int topMargin = (mMaxVisible - index - 1) * itemSpace;
		ViewHelper.setTranslationY(view, topMargin);
		ViewHelper.setAlpha(view, mNextAdapterPosition == 0 ? 1 : 0.5f);

		LayoutParams params = (LayoutParams) view.getLayoutParams();
		if (params == null) {
			params = new LayoutParams(LayoutParams.MATCH_PARENT,
					LayoutParams.WRAP_CONTENT);
		}
		addViewInLayout(view, 0, params);

		mNextAdapterPosition += 1;
	}
	// requestLayout();
}
 
Example #29
Source File: FlexibleSpaceWithImageRecyclerViewActivity.java    From Android-ObservableScrollView with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void setPivotXToTitle() {
    Configuration config = getResources().getConfiguration();
    if (Build.VERSION_CODES.JELLY_BEAN_MR1 <= Build.VERSION.SDK_INT
            && config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
        ViewHelper.setPivotX(mTitleView, findViewById(android.R.id.content).getWidth());
    } else {
        ViewHelper.setPivotX(mTitleView, 0);
    }
}
 
Example #30
Source File: MaterialContentOverflow.java    From MaterialContentOverflow with Apache License 2.0 5 votes vote down vote up
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {

    fabTotalHeight = fab.getHeight() +
            fabMargin + /*bottom margin*/
            fabMargin;  /*top margin*/

    initialYPosition = getInitialYPosition();

    if (overflowGestureListener.isOpened() && !changed) {
        ViewHelper.setY(this, 0f);
    } else {
        ViewHelper.setY(this, initialYPosition);
    }

    overflowGestureListener.setInitialYPosition(initialYPosition);

    if (!isInEditMode()) {
        //measured on device
        contentFrame.setPadding(0, fabTotalHeight / 2, 0, 0);
    } else {
        //measured on visual editor
        contentFrame.setPadding(0, fabTotalHeight, 0, 0);
    }

    super.onLayout(changed, left, top, right, bottom);
}