Java Code Examples for com.nineoldandroids.view.ViewHelper#setAlpha()

The following examples show how to use com.nineoldandroids.view.ViewHelper#setAlpha() . 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: FloatingLabelEditText.java    From FloatingLabelLayout with Apache License 2.0 6 votes vote down vote up
/**
 * Hide the label using an animation
 */
private void hideLabel() {
    ViewHelper.setAlpha(mLabel, 1f);
    ViewHelper.setTranslationY(mLabel, 0f);
    ViewPropertyAnimator.animate(mLabel)
            .alpha(0f)
            .translationY(mLabel.getHeight())
            .setDuration(ANIMATION_DURATION)
            .setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    mLabel.setVisibility(View.GONE);
                }
            }).start();

}
 
Example 2
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 3
Source File: ViewAnimator.java    From ListViewAnimations with Apache License 2.0 6 votes vote down vote up
/**
 * Animates given View.
 *
 * @param view the View that should be animated.
 */
private void animateView(final int position, @NonNull final View view, @NonNull final Animator[] animators) {
    if (mAnimationStartMillis == -1) {
        mAnimationStartMillis = SystemClock.uptimeMillis();
    }

    ViewHelper.setAlpha(view, 0);

    AnimatorSet set = new AnimatorSet();
    set.playTogether(animators);
    set.setStartDelay(calculateAnimationDelay(position));
    set.setDuration(mAnimationDurationMillis);
    set.start();

    mAnimators.put(view.hashCode(), set);
}
 
Example 4
Source File: AnimationAdapter.java    From android-open-project-demo with Apache License 2.0 6 votes vote down vote up
private void animateView(final ViewGroup parent, final 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 5
Source File: MaterialLeanBack.java    From MaterialLeanBack with Apache License 2.0 6 votes vote down vote up
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

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

    imageBackground = (ImageView) findViewById(R.id.mlb_imageBackground);
    imageBackgroundOverlay = findViewById(R.id.mlb_imageBackgroundOverlay);

    if (settings.backgroundId != null)
        imageBackground.setBackgroundDrawable(ContextCompat.getDrawable(getContext(), settings.backgroundId));

    if (settings.backgroundOverlay != null)
        ViewHelper.setAlpha(imageBackgroundOverlay, settings.backgroundOverlay);
    if (settings.backgroundOverlayColor != null)
        imageBackgroundOverlay.setBackgroundColor(settings.backgroundOverlayColor);

    recyclerView = (RecyclerView) findViewById(R.id.mlb_recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
}
 
Example 6
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 7
Source File: IndicatorView.java    From MousePaint with MIT License 5 votes vote down vote up
public void alphaDismiss(boolean isAnimation){
    if(isAnimation) {
        ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(this, "alpha", 1, 0);
        objectAnimator.setDuration(300);
        objectAnimator.start();
    }else{
        ViewHelper.setAlpha(this,0);
    }
}
 
Example 8
Source File: SwipeTouchListener.java    From ListViewAnimations with Apache License 2.0 5 votes vote down vote up
private boolean handleMoveEvent(@Nullable final View view, @NonNull final MotionEvent motionEvent) {
    if (mVelocityTracker == null || mCurrentView == null) {
        return false;
    }

    mVelocityTracker.addMovement(motionEvent);

    float deltaX = motionEvent.getX() - mDownX;
    float deltaY = motionEvent.getY() - mDownY;

    if (Math.abs(deltaX) > mSlop && Math.abs(deltaX) > Math.abs(deltaY)) {
        if (!mSwiping) {
            mActiveSwipeCount++;
            onStartSwipe(mCurrentView, mCurrentPosition);
        }
        mSwiping = true;
        mListViewWrapper.getListView().requestDisallowInterceptTouchEvent(true);

        /* Cancel ListView's touch (un-highlighting the item) */
        if (view != null) {
            MotionEvent cancelEvent = MotionEvent.obtain(motionEvent);
            cancelEvent.setAction(MotionEvent.ACTION_CANCEL | motionEvent.getActionIndex() << MotionEvent.ACTION_POINTER_INDEX_SHIFT);
            view.onTouchEvent(cancelEvent);
            cancelEvent.recycle();
        }
    }

    if (mSwiping) {
        if (mCanDismissCurrent) {
            ViewHelper.setTranslationX(mSwipingView, deltaX);
            ViewHelper.setAlpha(mSwipingView, Math.max(mMinimumAlpha, Math.min(1, 1 - 2 * Math.abs(deltaX) / mViewWidth)));
        } else {
            ViewHelper.setTranslationX(mSwipingView, deltaX * 0.1f);
        }
        return true;
    }
    return false;
}
 
Example 9
Source File: ExpandHeaderView.java    From PullRefreshView with Apache License 2.0 5 votes vote down vote up
@Override
protected void onStateChange(int state) {
    this.state = state;
    for (Animator animator : animators) {
        animator.cancel();
    }
    animators.clear();
    stateImg.setVisibility(View.INVISIBLE);
    progress.setVisibility(View.VISIBLE);
    ViewHelper.setAlpha(progress, 1f);
    switch (state) {
        case NONE:
            break;
        case PULLING:
            break;
        case LOOSENT_O_REFRESH:
            break;
        case REFRESHING:
            animators.add(AnimUtil.startRotation(progress, ViewHelper.getRotation(progress) + 359.99f, 500, 0, -1));
            break;
        case REFRESH_CLONE:
            animators.add(AnimUtil.startShow(stateImg, 0.1f, 400, 200));
            animators.add(AnimUtil.startHide(progress));
            break;

    }

}
 
Example 10
Source File: JazzyViewPager.java    From school_shop with MIT License 5 votes vote down vote up
protected void animateFade(View left, View right, float positionOffset) {
	if (left != null) {
		ViewHelper.setAlpha(left, 1-positionOffset);
	}
	if (right != null) {
		ViewHelper.setAlpha(right, positionOffset);
	}
}
 
Example 11
Source File: ExpandFooterView.java    From PullRefreshView with Apache License 2.0 5 votes vote down vote up
@Override
protected void onStateChange(int state) {
    this.state = state;
    for (Animator animator : animators) {
        animator.cancel();
    }
    animators.clear();
    stateImg.setVisibility(View.INVISIBLE);
    progress.setVisibility(View.VISIBLE);
    ViewHelper.setAlpha(progress, 1f);
    switch (state) {
        case NONE:
            break;
        case PULLING:
            break;
        case LOOSENT_O_LOAD:
            break;
        case LOADING:
            animators.add(AnimUtil.startRotation(progress, ViewHelper.getRotation(progress) + 359.99f, 500, 0, -1));
            break;
        case LOAD_CLONE:
            animators.add(AnimUtil.startShow(stateImg, 0.1f, 400, 200));
            animators.add(AnimUtil.startHide(progress));
            break;

    }

}
 
Example 12
Source File: LockHeaderView.java    From PullRefreshView with Apache License 2.0 5 votes vote down vote up
@Override
protected void onStateChange(int state) {
    this.state = state;
    for (Animator animator : animators) {
        animator.cancel();
    }
    animators.clear();
    stateImg.setVisibility(View.INVISIBLE);
    progress.setVisibility(View.INVISIBLE);
    ViewHelper.setAlpha(progress, 1f);
    switch (state) {
        case NONE:
            break;
        case PULLING:
            break;
        case LOOSENT_O_REFRESH:
            break;
        case REFRESHING:
            animators.add(AnimUtil.startShow(progress, 0.1f, 200, 0));
            animators.add(AnimUtil.startRotation(progress, ViewHelper.getRotation(progress) + 359.99f, 500, 0, -1));
            break;
        case REFRESH_CLONE:
            animators.add(AnimUtil.startShow(stateImg, 0.1f, 400, 200));
            animators.add(AnimUtil.startHide(progress));
            break;

    }

}
 
Example 13
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 14
Source File: MenuRVAdapter.java    From MousePaint with MIT License 5 votes vote down vote up
private void animation(MenuVH menuVH) {

        ViewHelper.setAlpha(menuVH.itemView, 0);

        ViewHelper.setTranslationY(menuVH.itemView, 300);
        ObjectAnimator translationY = ObjectAnimator.ofFloat(menuVH.itemView, "translationY", 500, 0);
        translationY.setDuration(300);
        translationY.setInterpolator(new OvershootInterpolator(1.6f));
        ObjectAnimator alphaIn = ObjectAnimator.ofFloat(menuVH.itemView, "alpha", 0, 1);
        alphaIn.setDuration(100);
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(translationY, alphaIn);
        animatorSet.setStartDelay(30 * menuVH.getAdapterPosition());
        animatorSet.start();
    }
 
Example 15
Source File: FullCompassFragment.java    From android_gisapp with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void updateCompass(float azimuth) {
    float alpha = 1f;
    if (mShowMagnetic) {
        alpha = .3f;
    }

    ViewHelper.setAlpha(mCompassNeedleMagnetic, alpha);
    ViewHelper.setAlpha(mCompassNeedle, alpha);

    super.updateCompass(azimuth);
}
 
Example 16
Source File: MainActivity.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
@Override
public void onDrag(View view, float delta) {
    if (fragmentList.get(display.getCurrentItem()) instanceof RecentFragment) {
        View icon = ((RecentFragment) fragmentList.get(display.getCurrentItem())).getIcon();
        if (icon != null) {
            ViewHelper.setAlpha(icon, (1 - delta));
        }
    }
}
 
Example 17
Source File: SlidingUpBaseActivity.java    From Android-ObservableScrollView with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(getLayoutResId());

    mToolbar = (Toolbar) findViewById(R.id.toolbar);

    setSupportActionBar(mToolbar);
    ViewHelper.setScaleY(mToolbar, 0);
    ActionBar ab = getSupportActionBar();
    if (ab != null) {
        ab.setHomeButtonEnabled(true);
        ab.setDisplayHomeAsUpEnabled(true);
        ab.setTitle("");
    }

    mToolbarColor = getResources().getColor(R.color.primary);
    mToolbar.setBackgroundColor(Color.TRANSPARENT);
    mToolbar.setTitle("");

    mFlexibleSpaceImageHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);
    mIntersectionHeight = getResources().getDimensionPixelSize(R.dimen.intersection_height);
    mHeaderBarHeight = getResources().getDimensionPixelSize(R.dimen.header_bar_height);
    mSlidingSlop = getResources().getDimensionPixelSize(R.dimen.sliding_slop);
    mActionBarSize = getActionBarSize();
    mColorPrimary = getResources().getColor(R.color.primary);
    mSlidingHeaderBlueSize = getResources().getDimensionPixelSize(R.dimen.sliding_overlay_blur_size);

    mHeader = findViewById(R.id.header);
    mHeaderBar = findViewById(R.id.header_bar);
    mHeaderOverlay = findViewById(R.id.header_overlay);
    mHeaderFlexibleSpace = findViewById(R.id.header_flexible_space);
    mImageView = findViewById(R.id.image);
    mImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            slideOnClick();
        }
    });
    mScrollable = createScrollable();

    mFab = findViewById(R.id.fab);
    mFab.setOnClickListener(fabClickListener);
    mFabMargin = getResources().getDimensionPixelSize(R.dimen.margin_standard);

    mInterceptionLayout = (TouchInterceptionFrameLayout) findViewById(R.id.scroll_wrapper);
    mInterceptionLayout.setScrollInterceptionListener(mInterceptionListener);
    mTitle = (TextView) findViewById(R.id.title);
    mTitle.setText(getTitle());
    mToolbarTitle = (TextView) findViewById(R.id.toolbar_title);
    mToolbarTitle.setText(mTitle.getText());
    ViewHelper.setAlpha(mToolbarTitle, 0);
    ViewHelper.setTranslationY(mTitle, (mHeaderBarHeight - mActionBarSize) / 2);

    if (savedInstanceState == null) {
        mSlidingState = SLIDING_STATE_BOTTOM;
    }

    ScrollUtils.addOnGlobalLayoutListener(mInterceptionLayout, new Runnable() {
        @Override
        public void run() {
            if (mFab != null) {
                ViewHelper.setTranslationX(mFab, mTitle.getWidth() - mFabMargin - mFab.getWidth());
                ViewHelper.setTranslationY(mFab, ViewHelper.getX(mTitle) - (mFab.getHeight() / 2));
            }
            changeSlidingState(mSlidingState, false);
        }
    });
}
 
Example 18
Source File: FadeEffect.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public void initView(View view, int i, int j)
{
    ViewHelper.setAlpha(view, 0.0F);
}
 
Example 19
Source File: BaseTransformer.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
/**
 * Called each {@link #transformPage(android.view.View, float)} before {{@link #onTransform(android.view.View, float)} is called.
 *
 * @param view
 * @param position
 */
protected void onPreTransform(View view, float position) {
    final float width = view.getWidth();

    ViewHelper.setRotationX(view,0);
    ViewHelper.setRotationY(view,0);
    ViewHelper.setRotation(view,0);
    ViewHelper.setScaleX(view,1);
    ViewHelper.setScaleY(view,1);
    ViewHelper.setPivotX(view,0);
    ViewHelper.setPivotY(view,0);
    ViewHelper.setTranslationY(view,0);
    ViewHelper.setTranslationX(view,isPagingEnabled() ? 0f : -width * position);

    if (hideOffscreenPages()) {
        ViewHelper.setAlpha(view,position <= -1f || position >= 1f ? 0f : 1f);
    } else {
        ViewHelper.setAlpha(view,1f);
    }
    if(mCustomAnimationInterface != null){
        if(h.containsKey(view) == false || h.get(view).size() == 1){
            if(position > -1 && position < 1){
                if(h.get(view) == null){
                    h.put(view,new ArrayList<Float>());
                }
                h.get(view).add(position);
                if(h.get(view).size() == 2){
                    float zero = h.get(view).get(0);
                    float cha = h.get(view).get(1) - h.get(view).get(0);
                    if(zero > 0){
                        if(cha > -1 && cha < 0){
                            //in
                            mCustomAnimationInterface.onPrepareNextItemShowInScreen(view);
                        }else{
                            //out
                            mCustomAnimationInterface.onPrepareCurrentItemLeaveScreen(view);
                        }
                    }else{
                        if(cha > -1 && cha < 0){
                            //out
                            mCustomAnimationInterface.onPrepareCurrentItemLeaveScreen(view);
                        }else{
                            //in
                            mCustomAnimationInterface.onPrepareNextItemShowInScreen(view);
                        }
                    }
                }
            }
        }
    }
}
 
Example 20
Source File: SwipeTouchListener.java    From ListViewAnimations with Apache License 2.0 2 votes vote down vote up
/**
 * Restores the {@link android.view.View}'s {@code alpha} and {@code translationX} values.
 * Users of this class should call this method when recycling {@code View}s.
 *
 * @param view the {@code View} whose presentation should be restored.
 */
protected void restoreViewPresentation(@NonNull final View view) {
    View swipedView = getSwipeView(view);
    ViewHelper.setAlpha(swipedView, 1);
    ViewHelper.setTranslationX(swipedView, 0);
}