當前位置: 首頁>>代碼示例>>Java>>正文


Java ViewCompat.setAlpha方法代碼示例

本文整理匯總了Java中android.support.v4.view.ViewCompat.setAlpha方法的典型用法代碼示例。如果您正苦於以下問題:Java ViewCompat.setAlpha方法的具體用法?Java ViewCompat.setAlpha怎麽用?Java ViewCompat.setAlpha使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v4.view.ViewCompat的用法示例。


在下文中一共展示了ViewCompat.setAlpha方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: endChangeAnimationIfNecessary

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
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;
}
 
開發者ID:SalmanTKhan,項目名稱:MyAnimeViewer,代碼行數:17,代碼來源:BaseItemAnimator.java

示例2: onItemScrolled

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
private void onItemScrolled(RecyclerView recyclerView, int dx, int dy) {
    final float ratio = computeRatio(recyclerView);

    final float footerRatio = Math.max(0, Math.min(FOOTER_RATIO_START, ratio) - FOOTER_RATIO_DIFF) / FOOTER_RATIO_MAX;
    final float avatarRatio = Math.max(0, Math.min(AVATAR_RATIO_START, ratio) - AVATAR_RATIO_DIFF) / AVATAR_RATIO_MAX;
    final float answerRatio = Math.max(0, Math.min(ANSWER_RATIO_START, ratio) - ANSWER_RATIO_DIFF) / ANSWER_RATIO_MAX;
    final float middleRatio = Math.max(0, Math.min(MIDDLE_RATIO_START, ratio) - MIDDLE_RATIO_DIFF) / MIDDLE_RATIO_MAX;

    ViewCompat.setPivotY(mFooter, 0);
    ViewCompat.setScaleY(mFooter, footerRatio);
    ViewCompat.setAlpha(mFooter, footerRatio);

    ViewCompat.setPivotY(mMiddleAnswer, mMiddleAnswer.getHeight());
    ViewCompat.setScaleY(mMiddleAnswer, 1f - answerRatio);
    ViewCompat.setAlpha(mMiddleAnswer, 0.5f - answerRatio);

    ViewCompat.setAlpha(mHeaderCaption1, answerRatio);
    ViewCompat.setAlpha(mHeaderCaption2, 1f - answerRatio);

    final View mc2 = mMiddleCollapsible.get(1);
    ViewCompat.setPivotX(mc2, 0);
    ViewCompat.setPivotY(mc2, mc2.getHeight() / 2);

    for (final View view : mMiddleCollapsible) {
        ViewCompat.setScaleX(view, avatarRatio);
        ViewCompat.setScaleY(view, avatarRatio);
        ViewCompat.setAlpha(view, avatarRatio);
    }

    final ViewGroup.LayoutParams lp = mMiddle.getLayoutParams();
    lp.height = m120dp - (int) (m10dp * (1f - middleRatio));
    mMiddle.setLayoutParams(lp);
}
 
開發者ID:Ramotion,項目名稱:showroom-android,代碼行數:34,代碼來源:OuterItem.java

示例3: handleLeftPage

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
@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);
}
 
開發者ID:devzwy,項目名稱:KUtils,代碼行數:12,代碼來源:ZoomFadePageTransformer.java

示例4: handleRightPage

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
@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);
}
 
開發者ID:devzwy,項目名稱:NeiHanDuanZiTV,代碼行數:9,代碼來源:DepthPageTransformer.java

示例5: handleRightPage

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
@Override
public void handleRightPage(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));
}
 
開發者ID:liu-xiao-dong,項目名稱:JD-Test,代碼行數:11,代碼來源:ZoomPageTransformer.java

示例6: addMenuItems

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
private void addMenuItems() {
    ViewCompat.setAlpha(menuItemsLayout, 1f);
    for (int i = 0; i < navigationMenu.size(); i++) {
        MenuItem menuItem = navigationMenu.getItem(i);
        if (menuItem.isVisible()) {
            menuItemsLayout.addView(createFabMenuItem(menuItem));
        }
    }
    animateFabMenuItemsIn();
}
 
開發者ID:Alcatraz323,項目名稱:MaterialOCR,代碼行數:11,代碼來源:FabSpeedDial.java

示例7: onPageScrolled

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    mPageScrollPosition = position;
    mPageScrollPositionOffset = positionOffset;

    if (mTipTv != null) {
        if (mTips != null && mTips.size() > 0) {
            mTipTv.setVisibility(View.VISIBLE);

            int leftPosition = position % mTips.size();
            int rightPosition = (position + 1) % mTips.size();
            if (rightPosition < mTips.size() && leftPosition < mTips.size()) {
                if (positionOffset > 0.5) {
                    mTipTv.setText(mTips.get(rightPosition));
                    ViewCompat.setAlpha(mTipTv, positionOffset);
                } else {
                    ViewCompat.setAlpha(mTipTv, 1 - positionOffset);
                    mTipTv.setText(mTips.get(leftPosition));
                }
            }
        } else {
            mTipTv.setVisibility(View.GONE);
        }
    }

    if (mOnPageChangeListener != null) {
        mOnPageChangeListener.onPageScrolled(position % mViews.size(), positionOffset, positionOffsetPixels);
    }
}
 
開發者ID:devzwy,項目名稱:NeiHanDuanZiTV,代碼行數:30,代碼來源:BGABanner.java

示例8: onPositionChange

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
@Override
public void onPositionChange(@SwipeToRefreshLayout.SwipeDirection int direction, @SwipeToRefreshLayout.State int state, int refreshPoint, int range, int currentX, int currentY, int lastX, int lastY, float touchX, float touchY) {
    float fraction = currentX >= refreshPoint? 1: currentX * 1.0f/refreshPoint;
    ViewCompat.setScaleX(mIndicatorView, fraction);
    ViewCompat.setScaleY(mIndicatorView, fraction);
    ViewCompat.setRotation(mIndicatorView, currentX * 1.0f/refreshPoint * 360);
    ViewCompat.setAlpha(mIndicatorView, fraction);

    if (currentX < refreshPoint){
        mText.setText("拖拽刷新");
    }else{
        mText.setText("釋放刷新");
    }
}
 
開發者ID:zhouphenix,項目名稱:Multi-SwipeToRefreshLayout,代碼行數:15,代碼來源:IndicatorsRefreshHeader.java

示例9: reset

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
@Override
public void reset() {
    mCircleView.clearAnimation();
    mProgress.stop();
    mCircleView.setVisibility(View.GONE);

    mCircleView.getBackground().setAlpha(MAX_ALPHA);
    mProgress.setAlpha(MAX_ALPHA);
    ViewCompat.setScaleX(mCircleView, 0);
    ViewCompat.setScaleY(mCircleView, 0);
    ViewCompat.setAlpha(mCircleView, 1);
}
 
開發者ID:Justson,項目名稱:AgentWebX5,代碼行數:13,代碼來源:ProgressLayout.java

示例10: removePendingDismisses

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
/**
 * Will delete all pending dismisses.
 * Will call callback onDismiss for all pending dismisses.
 * Will reset all cell height to originalHeight.
 *
 * @param originalHeight is the height of the cell before animation.
 */
private void removePendingDismisses(int originalHeight) {
    // No active animations, process all pending dismisses.
    // Sort by descending position
    Collections.sort(pendingDismisses);

    int[] dismissPositions = new int[pendingDismisses.size()];
    for (int i = pendingDismisses.size() - 1; i >= 0; i--) {
        dismissPositions[i] = pendingDismisses.get(i).position;
    }
    swipeListView.onDismiss(dismissPositions);

    ViewGroup.LayoutParams lp;
    for (PendingDismissData pendingDismiss : pendingDismisses) {
        // Reset view presentation
        if (pendingDismiss.view != null) {
            ViewCompat.setAlpha(pendingDismiss.view, 1f);
            ViewCompat.setTranslationX(pendingDismiss.view, 0);
            lp = pendingDismiss.view.getLayoutParams();
            lp.height = originalHeight;
            pendingDismiss.view.setLayoutParams(lp);
        }
    }

    resetPendingDismisses();

}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:34,代碼來源:SwipeListViewTouchListener.java

示例11: doHide

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
public void doHide(boolean fromSystem) {
    if (this.mCurrentShowAnim != null) {
        this.mCurrentShowAnim.cancel();
    }
    if (this.mCurWindowVisibility == 0 && ALLOW_SHOW_HIDE_ANIMATIONS && (this.mShowHideAnimationEnabled || fromSystem)) {
        ViewCompat.setAlpha(this.mContainerView, 1.0f);
        this.mContainerView.setTransitioning(true);
        ViewPropertyAnimatorCompatSet anim = new ViewPropertyAnimatorCompatSet();
        float endingY = (float) (-this.mContainerView.getHeight());
        if (fromSystem) {
            int[] topLeft = new int[]{0, 0};
            this.mContainerView.getLocationInWindow(topLeft);
            endingY -= (float) topLeft[1];
        }
        ViewPropertyAnimatorCompat a = ViewCompat.animate(this.mContainerView).translationY(endingY);
        a.setUpdateListener(this.mUpdateListener);
        anim.play(a);
        if (this.mContentAnimations && this.mContentView != null) {
            anim.play(ViewCompat.animate(this.mContentView).translationY(endingY));
        }
        anim.setInterpolator(sHideInterpolator);
        anim.setDuration(250);
        anim.setListener(this.mHideListener);
        this.mCurrentShowAnim = anim;
        anim.start();
        return;
    }
    this.mHideListener.onAnimationEnd(null);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:30,代碼來源:WindowDecorActionBar.java

示例12: animateChange

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
@Override
    public boolean animateChange(ViewHolder oldHolder, ViewHolder newHolder,
                                 int fromX, int fromY, int toX, int toY) {
//        if (oldHolder != newHolder) {
//            if (oldHolder != null) {
//                dispatchChangeFinished(oldHolder, true);
//            }
//            if (newHolder != null) {
//                dispatchChangeFinished(newHolder, false);
//            }
//        } else if (oldHolder != null) {
//            dispatchChangeFinished(oldHolder, true);
//        }
//        return false;
        if (oldHolder == newHolder) {
            // Don't know how to run change animations when the same view holder is re-used.
            // run a move animation to handle position changes.
            if ((fromX - toX) == 0 && (fromY - toY) == 0) {
                dispatchMoveFinished(oldHolder);
                return false;
            }
            return animateMove(oldHolder, fromX, fromY, toX, 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) {
            // 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;
    }
 
開發者ID:XndroidDev,項目名稱:Xndroid,代碼行數:44,代碼來源:HorizontalItemAnimator.java

示例13: handleLeftPage

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
@Override
public void handleLeftPage(View view, float position) {
    ViewCompat.setAlpha(view, mMinScale + (1 - mMinScale) * (1 + position));
}
 
開發者ID:weileng11,項目名稱:KUtils-master,代碼行數:5,代碼來源:AlphaPageTransformer.java

示例14: update

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
public void update(RecyclerView referenceList, float dx, float dy) {
    if (indexList != null && indexList.getChildCount() > 2) {
        show();
        updatePosBasedOnReferenceList(referenceList);

        View firstVisibleView = indexList.getChildAt(0);
        View secondVisibleView = indexList.getChildAt(1);


        TextView firstRowIndex = (TextView) firstVisibleView.findViewById(R.id.section_title);
        TextView secondRowIndex = (TextView) secondVisibleView.findViewById(R.id.section_title);

        int visibleRange = indexList.getChildCount();
        int actual = indexList.getChildPosition(firstVisibleView);
        int next = actual + 1;
        int last = actual + visibleRange;

        Drawable drawable = activity.getResources().getDrawable(R.drawable.circle_white_bg);
        int backGroundColor = ToolbarContentTintHelper.toolbarTitleColor(activity, ThemeStore.primaryColor(activity));
        stickyIndex.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(backGroundColor)));
        drawable.setColorFilter(backGroundColor, PorterDuff.Mode.SRC_IN);
        stickyIndex.setBackground(drawable);

        // RESET STICKY LETTER INDEX
        stickyIndex.setText(String.valueOf(getIndexContext(firstRowIndex)).toUpperCase());
        stickyIndex.setVisibility(TextView.VISIBLE);
        ViewCompat.setAlpha(firstRowIndex, 1);

        if (dy > 0) {
            // USER SCROLLING DOWN THE RecyclerView
            if (next <= last) {
                if (isHeader(firstRowIndex, secondRowIndex)) {
                    stickyIndex.setVisibility(TextView.INVISIBLE);
                    firstRowIndex.setVisibility(TextView.VISIBLE);
                    ViewCompat.setAlpha(firstRowIndex, (1 - (Math.abs(ViewCompat.getY(firstVisibleView)) / firstRowIndex.getHeight())));
                    secondRowIndex.setVisibility(TextView.VISIBLE);
                } else {
                    firstRowIndex.setVisibility(TextView.INVISIBLE);
                    stickyIndex.setVisibility(TextView.VISIBLE);
                }
            }
        } else if (dy < 0) {
            // USER IS SCROLLING UP THE RecyclerVIew
            if (next <= last) {
                // RESET FIRST ROW STATE
                firstRowIndex.setVisibility(TextView.INVISIBLE);
                if ((isHeader(firstRowIndex, secondRowIndex) || (getIndexContext(firstRowIndex) != getIndexContext(secondRowIndex))) && isHeader(firstRowIndex, secondRowIndex)) {
                    stickyIndex.setVisibility(TextView.INVISIBLE);
                    firstRowIndex.setVisibility(TextView.VISIBLE);
                    ViewCompat.setAlpha(firstRowIndex, 1 - (Math.abs(ViewCompat.getY(firstVisibleView) / firstRowIndex.getHeight())));
                    secondRowIndex.setVisibility(TextView.VISIBLE);
                } else {
                    secondRowIndex.setVisibility(TextView.INVISIBLE);
                }
            }
        }

        if (stickyIndex.getVisibility() == TextView.VISIBLE) {
            firstRowIndex.setVisibility(TextView.INVISIBLE);
        }
    } else {
        hide();
    }
}
 
開發者ID:aliumujib,項目名稱:Orin,代碼行數:65,代碼來源:IndexLayoutManager.java

示例15: preAnimateAddImpl

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
@Override
protected boolean preAnimateAddImpl(final RecyclerView.ViewHolder holder) {
	ViewCompat.setTranslationY(holder.itemView, -holder.itemView.getHeight());
	ViewCompat.setAlpha(holder.itemView, 0);
	return true;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:7,代碼來源:SlideInDownAnimator.java


注:本文中的android.support.v4.view.ViewCompat.setAlpha方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。