Java Code Examples for android.support.v4.view.ViewCompat#setAlpha()
The following examples show how to use
android.support.v4.view.ViewCompat#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: ItemAnimator.java From GoogleFitExample with Apache License 2.0 | 6 votes |
@Override public boolean animateChange(RecyclerView.ViewHolder oldHolder, RecyclerView.ViewHolder newHolder, int fromX, int fromY, int toX, int toY) { if(oldHolder != null) { //oldHolder.itemView.setVisibility(View.INVISIBLE); dispatchChangeFinished(oldHolder, true); } if(newHolder != null) { //newHolder.itemView.setVisibility(View.VISIBLE); ViewCompat.setAlpha(newHolder.itemView, 1.0F); dispatchChangeFinished(newHolder, false); } return false; }
Example 2
Source File: ClassifyItemAnimator.java From ClassifyView with Apache License 2.0 | 6 votes |
private boolean endChangeAnimationIfNecessary(ChangeInfo changeInfo, RecyclerView.ViewHolder item) { boolean oldItem = false; if (changeInfo.newHolder == item) { changeInfo.newHolder = null; } else if (changeInfo.oldHolder == item) { changeInfo.oldHolder = null; oldItem = true; } else { return false; } ViewCompat.setAlpha(item.itemView, 1); ViewCompat.setTranslationX(item.itemView, 0); ViewCompat.setTranslationY(item.itemView, 0); dispatchChangeFinished(item, oldItem); return true; }
Example 3
Source File: SwipeItemLayout.java From IndexRecyclerView with Apache License 2.0 | 6 votes |
/** * 打开或关闭滑动控件 * * @param isOpen 1表示打开,0表示关闭 */ private void slideTo(int isOpen) { if (isOpen == 1) { mBottomView.setVisibility(VISIBLE); ViewCompat.setAlpha(mBottomView, 1.0f); mCurrentStatus = Status.Opened; if (mDelegate != null) { mDelegate.onSwipeItemLayoutOpened(this); } } else { mBottomView.setVisibility(INVISIBLE); mCurrentStatus = Status.Closed; if (mDelegate != null) { mDelegate.onSwipeItemLayoutClosed(this); } } mPreStatus = mCurrentStatus; mTopLeft = getCloseOrOpenTopViewFinalLeft(isOpen); requestLayout(); }
Example 4
Source File: HorizontalItemAnimator.java From JumpGo with Mozilla Public License 2.0 | 6 votes |
private boolean endChangeAnimationIfNecessary(ChangeInfo changeInfo, ViewHolder item) { boolean oldItem = false; if (changeInfo.newHolder == item) { changeInfo.newHolder = null; } else if (changeInfo.oldHolder == item) { changeInfo.oldHolder = null; oldItem = true; } else { return false; } ViewCompat.setAlpha(item.itemView, 1); ViewCompat.setTranslationX(item.itemView, 0); ViewCompat.setTranslationY(item.itemView, 0); dispatchChangeFinished(item, oldItem); return true; }
Example 5
Source File: DefaultItemAnimator.java From Mupdf with Apache License 2.0 | 6 votes |
@Override public boolean animateChange(ViewHolder oldHolder, ViewHolder newHolder, int fromX, int fromY, int toX, int toY) { final float prevTranslationX = ViewCompat.getTranslationX(oldHolder.itemView); final float prevTranslationY = ViewCompat.getTranslationY(oldHolder.itemView); final float prevAlpha = ViewCompat.getAlpha(oldHolder.itemView); resetAnimation(oldHolder); int deltaX = (int) (toX - fromX - prevTranslationX); int deltaY = (int) (toY - fromY - prevTranslationY); // recover prev translation state after ending animation ViewCompat.setTranslationX(oldHolder.itemView, prevTranslationX); ViewCompat.setTranslationY(oldHolder.itemView, prevTranslationY); ViewCompat.setAlpha(oldHolder.itemView, prevAlpha); if (newHolder != null && newHolder.itemView != null) { // carry over translation values resetAnimation(newHolder); ViewCompat.setTranslationX(newHolder.itemView, -deltaX); ViewCompat.setTranslationY(newHolder.itemView, -deltaY); ViewCompat.setAlpha(newHolder.itemView, 0); } mPendingChanges.add(new ChangeInfo(oldHolder, newHolder, fromX, fromY, toX, toY)); return true; }
Example 6
Source File: DraggerView.java From Dragger with Apache License 2.0 | 5 votes |
@Override public void onSpringUpdate(Spring spring) { double val = spring.getCurrentValue(); switch (dragPosition) { case LEFT: ViewCompat.setTranslationX(dragView, (float) SpringUtil.mapValueFromRangeToRange(val, 0, 1, 0, -dragView.getWidth())); break; case RIGHT: ViewCompat.setTranslationX(dragView, (float) SpringUtil.mapValueFromRangeToRange(val, 0, 1, 0, dragView.getWidth())); break; case TOP: ViewCompat.setTranslationY(dragView, (float) SpringUtil.mapValueFromRangeToRange(val, 0, 1, 0, dragView.getHeight())); break; case BOTTOM: ViewCompat.setTranslationY(dragView, (float) SpringUtil.mapValueFromRangeToRange(val, 0, 1, 0, -dragView.getHeight())); break; default: break; } ViewCompat.setAlpha(shadowView, (float) (MAX_ALPHA - SpringUtil.mapValueFromRangeToRange(val, 0, 1, 0, 1))); if (draggerCallback != null) { draggerCallback.onProgress(spring.getCurrentValue()); } }
Example 7
Source File: FlipHorizontalTransformer.java From LoyalNativeSlider with MIT License | 5 votes |
@Override protected void onTransform(View view, float position) { final float rotation = 180f * position; ViewCompat.setAlpha(view, rotation > 90f || rotation < -90f ? 0 : 1); ViewCompat.setPivotY(view,view.getHeight()*0.5f); ViewCompat.setPivotX(view,view.getWidth() * 0.5f); ViewCompat.setRotationY(view,rotation); }
Example 8
Source File: MaterialHeaderView.java From SprintNBA with Apache License 2.0 | 5 votes |
@Override public void onPull(MaterialRefreshLayout materialRefreshLayout, float fraction) { if (materialWaveView != null) { materialWaveView.onPull(materialRefreshLayout, fraction); } if (circleProgressBar != null) { circleProgressBar.onPull(materialRefreshLayout, fraction); float a = Util.limitValue(1, fraction); ViewCompat.setScaleX(circleProgressBar, a); ViewCompat.setScaleY(circleProgressBar, a); ViewCompat.setAlpha(circleProgressBar, a); } }
Example 9
Source File: ZoomCenterPageTransformer.java From JD-Test with Apache License 2.0 | 5 votes |
@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 10
Source File: ViewHelper.java From Nimingban with Apache License 2.0 | 5 votes |
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); // @TODO https://code.google.com/p/android/issues/detail?id=80863 // ViewCompat.setPivotY(v, v.getMeasuredHeight() / 2); v.setPivotY(v.getMeasuredHeight() / 2); ViewCompat.setPivotX(v, v.getMeasuredWidth() / 2); ViewCompat.animate(v).setInterpolator(null); }
Example 11
Source File: FabSpeedDial.java From FireFiles with Apache License 2.0 | 5 votes |
private View createFabMenuItem(MenuItem menuItem) { ViewGroup fabMenuItem = (ViewGroup) LayoutInflater.from(getContext()) .inflate(getMenuItemLayoutId(), this, false); FloatingActionButton miniFab = (FloatingActionButton) fabMenuItem.findViewById(R.id.mini_fab); FrameLayout cardView = (FrameLayout) fabMenuItem.findViewById(R.id.card_view); TextView titleView = (TextView) fabMenuItem.findViewById(R.id.title_view); fabMenuItemMap.put(miniFab, menuItem); cardViewMenuItemMap.put(cardView, menuItem); miniFab.setImageDrawable(menuItem.getIcon()); miniFab.setOnClickListener(this); cardView.setOnClickListener(this); ViewCompat.setAlpha(miniFab, 0f); ViewCompat.setAlpha(cardView, 0f); final CharSequence title = menuItem.getTitle(); if (!TextUtils.isEmpty(title) && miniFabTitlesEnabled) { //cardView.setCardBackgroundColor(miniFabTitleBackgroundTint.getDefaultColor()); titleView.setText(title); titleView.setTypeface(null, Typeface.BOLD); titleView.setTextColor(miniFabTitleTextColor); } else { fabMenuItem.removeView(cardView); } miniFab.setBackgroundTintList(miniFabBackgroundTint); if (Utils.hasLollipop()) { miniFab.setImageTintList(miniFabDrawableTint); } return fabMenuItem; }
Example 12
Source File: SweetSnackbar.java From SweetTips with Apache License 2.0 | 5 votes |
void animateChildrenOut(int delay, int duration) { ViewCompat.setAlpha(mMessageView, 1f); ViewCompat.animate(mMessageView).alpha(0f).setDuration(duration) .setStartDelay(delay).start(); if (mActionView.getVisibility() == VISIBLE) { ViewCompat.setAlpha(mActionView, 1f); ViewCompat.animate(mActionView).alpha(0f).setDuration(duration) .setStartDelay(delay).start(); } }
Example 13
Source File: DepthPageTransformer.java From KUtils with Apache License 2.0 | 5 votes |
@Override public void handleRightPage(View view, float position) { ViewCompat.setAlpha(view, 1 - position); ViewCompat.setTranslationX(view, -view.getWidth() * position); float scale = mMinScale + (1 - mMinScale) * (1 - position); ViewCompat.setScaleX(view, scale); ViewCompat.setScaleY(view, scale); }
Example 14
Source File: ZoomPageTransformer.java From KUtils with Apache License 2.0 | 5 votes |
@Override public void handleLeftPage(View view, float position) { float scale = Math.max(mMinScale, 1 + position); float vertMargin = view.getHeight() * (1 - scale) / 2; float horzMargin = view.getWidth() * (1 - scale) / 2; ViewCompat.setTranslationX(view, horzMargin - vertMargin / 2); ViewCompat.setScaleX(view, scale); ViewCompat.setScaleY(view, scale); ViewCompat.setAlpha(view, mMinAlpha + (scale - mMinScale) / (1 - mMinScale) * (1 - mMinAlpha)); }
Example 15
Source File: SwipeItem.java From Hify with MIT License | 5 votes |
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // measure childs mSwipeInfo = getChildAt(0); mSwipeUndo = getChildAt(1); mSwipeItem = getChildAt(2); if (mFirstLayout) { switch (mState) { case LEFT_UNDO: mSwipeInfo.setVisibility(GONE); mSwipeUndo.setVisibility(VISIBLE); break; case RIGHT_UNDO: mSwipeInfo.setVisibility(GONE); mSwipeUndo.setVisibility(VISIBLE); break; case NORMAL: mSwipeUndo.setVisibility(GONE); mSwipeInfo.setVisibility(VISIBLE); } ViewCompat.setAlpha(mSwipeInfo, 1); ViewCompat.setAlpha(mSwipeUndo, 1); } measureChildWithMargins(mSwipeInfo, widthMeasureSpec, 0, heightMeasureSpec, 0); measureChildWithMargins(mSwipeUndo, widthMeasureSpec, 0, heightMeasureSpec, 0); measureChildWithMargins(mSwipeItem, widthMeasureSpec, 0, heightMeasureSpec, 0); setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), mSwipeItem.getMeasuredHeight()); mSwipeInfo.measure(MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY)); mSwipeUndo.measure(MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY)); mSwipeItem.measure(MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY)); }
Example 16
Source File: DefaultItemAnimator.java From letv with Apache License 2.0 | 4 votes |
public void endAnimation(ViewHolder item) { int i; View view = item.itemView; ViewCompat.animate(view).cancel(); for (i = this.mPendingMoves.size() - 1; i >= 0; i--) { if (((MoveInfo) this.mPendingMoves.get(i)).holder == item) { ViewCompat.setTranslationY(view, 0.0f); ViewCompat.setTranslationX(view, 0.0f); dispatchMoveFinished(item); this.mPendingMoves.remove(i); } } endChangeAnimation(this.mPendingChanges, item); if (this.mPendingRemovals.remove(item)) { ViewCompat.setAlpha(view, 1.0f); dispatchRemoveFinished(item); } if (this.mPendingAdditions.remove(item)) { ViewCompat.setAlpha(view, 1.0f); dispatchAddFinished(item); } for (i = this.mChangesList.size() - 1; i >= 0; i--) { ArrayList<ChangeInfo> changes = (ArrayList) this.mChangesList.get(i); endChangeAnimation(changes, item); if (changes.isEmpty()) { this.mChangesList.remove(i); } } for (i = this.mMovesList.size() - 1; i >= 0; i--) { ArrayList<MoveInfo> moves = (ArrayList) this.mMovesList.get(i); int j = moves.size() - 1; while (j >= 0) { if (((MoveInfo) moves.get(j)).holder == item) { ViewCompat.setTranslationY(view, 0.0f); ViewCompat.setTranslationX(view, 0.0f); dispatchMoveFinished(item); moves.remove(j); if (moves.isEmpty()) { this.mMovesList.remove(i); } } else { j--; } } } for (i = this.mAdditionsList.size() - 1; i >= 0; i--) { ArrayList<ViewHolder> additions = (ArrayList) this.mAdditionsList.get(i); if (additions.remove(item)) { ViewCompat.setAlpha(view, 1.0f); dispatchAddFinished(item); if (additions.isEmpty()) { this.mAdditionsList.remove(i); } } } if (this.mRemoveAnimations.remove(item)) { } if (this.mAddAnimations.remove(item)) { } if (this.mChangeAnimations.remove(item)) { } if (this.mMoveAnimations.remove(item)) { dispatchFinishedWhenDone(); } else { dispatchFinishedWhenDone(); } }
Example 17
Source File: GearLoadingLayout.java From GearLoadingProject with Apache License 2.0 | 4 votes |
private void selectShowAnimation(boolean showDialog) { if (mActivityContentView == null || isAnimating) return; if (showDialog) { mActivityContentView.addView(GearLoadingLayout.this); } this.showDialog = showDialog; float from = 0f; float to = 0f; boolean xAxis = false; boolean scaleDialog = false; switch (mShowMode) { case TOP: from = -mDialogHeight; to = 0; break; case BOTTOM: from = mDialogHeight; to = 0; break; case LEFT: from = -mDialogWidth; to = 0; xAxis = true; break; case RIGHT: from = mDialogWidth; to = 0; xAxis = true; break; case CENTER: scaleDialog = true; break; default: break; } setGearLayoutWrapperGravity(); applyStyle(); start(); if (scaleDialog) { ViewCompat.setScaleX(mGearLayoutWrapper, showDialog ? 0 : 1); ViewCompat.setScaleY(mGearLayoutWrapper, showDialog ? 0 : 1); ViewCompat.animate(mGearLayoutWrapper).scaleX(showDialog ? 1 : 0).scaleY(showDialog ? 1 : 0).setDuration(showDialogDuration).withStartAction(startAction).withEndAction(endAction).start(); } else { if (!xAxis) { ViewCompat.setTranslationY(mGearLayoutWrapper, showDialog ? from : to); ViewCompat.animate(mGearLayoutWrapper).translationY(showDialog ? to : from).setDuration(showDialogDuration).withStartAction(startAction).withEndAction(endAction).start(); } else { ViewCompat.setTranslationX(mGearLayoutWrapper, showDialog ? from : to); ViewCompat.animate(mGearLayoutWrapper).translationX(showDialog ? to : from).setDuration(showDialogDuration).withStartAction(startAction).withEndAction(endAction).start(); } } ViewCompat.setAlpha(mMainBackground, showDialog ? 0 : isEnableBlur ? 1 : mMainBackgroundAlpha); ViewCompat.animate(mMainBackground).alpha(showDialog ? isEnableBlur ? 1 : mMainBackgroundAlpha : 0).setDuration(showDialogDuration).start(); }
Example 18
Source File: SlideInUpAnimator.java From Nimingban with Apache License 2.0 | 4 votes |
@Override protected void preAnimateAddImpl(RecyclerView.ViewHolder holder) { ViewCompat.setTranslationY(holder.itemView, holder.itemView.getHeight()); ViewCompat.setAlpha(holder.itemView, 0); }
Example 19
Source File: AlphaPageTransformer.java From KUtils with Apache License 2.0 | 4 votes |
@Override public void handleInvisiblePage(View view, float position) { ViewCompat.setAlpha(view, 0); }
Example 20
Source File: FadeInAnimator.java From RecyclerviewAnimators with Apache License 2.0 | 4 votes |
@Override protected void preAnimateAddImpl(RecyclerView.ViewHolder holder) { ViewCompat.setAlpha(holder.itemView, 0); }