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


Java ViewCompat.getAlpha方法代碼示例

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


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

示例1: onUpdateViewAlpha

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
@Override
protected void onUpdateViewAlpha(@NonNull View view, float alpha) {
    final CardView card = ((CardView)view);
    final View alphaView = card.getChildAt(1);
    final View imageView = card.getChildAt(0);

    final boolean isLeftCard = alpha < 1;
    if (isLeftCard) {
        ViewCompat.setAlpha(alphaView, 0.9f - alpha);
        ViewCompat.setAlpha(imageView, 0.3f + alpha);
    } else {
        if (ViewCompat.getAlpha(alphaView) != 0) {
            ViewCompat.setAlpha(alphaView, 0f);
        }

        if (ViewCompat.getAlpha(imageView) != 1) {
            ViewCompat.setAlpha(imageView, 1f);
        }
    }
}
 
開發者ID:Ramotion,項目名稱:showroom-android,代碼行數:21,代碼來源:CardsUpdater.java

示例2: animateChange

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
@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);
    endAnimation(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
        endAnimation(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:angcyo,項目名稱:RLibrary,代碼行數:24,代碼來源:BaseItemAnimator.java

示例3: setImageDrawable

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
/**
 * change the image with a fade
 *
 * @param drawable
 * @param fadeDuration
 */
public static void setImageDrawable(final ImageView imageView, final Drawable drawable, final int fadeDuration) {
    final float alpha = ViewCompat.getAlpha(imageView);
    final ImageView viewToAnimate = imageView;

    fadeOut(viewToAnimate, fadeDuration, new ViewPropertyAnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(View view) {
            super.onAnimationEnd(view);
            //change the image when alpha=0

            imageView.setImageDrawable(drawable);

            //then fade to alpha=1
            fadeIn(viewToAnimate, alpha, fadeDuration, new ViewPropertyAnimatorListenerAdapter());
        }
    });
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:24,代碼來源:MaterialViewPagerImageHelper.java

示例4: animateChange

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
public boolean animateChange(ViewHolder oldHolder, ViewHolder newHolder, int fromX, int fromY, int toX, int toY) {
    if (oldHolder == newHolder) {
        return animateMove(oldHolder, fromX, fromY, toX, toY);
    }
    float prevTranslationX = ViewCompat.getTranslationX(oldHolder.itemView);
    float prevTranslationY = ViewCompat.getTranslationY(oldHolder.itemView);
    float prevAlpha = ViewCompat.getAlpha(oldHolder.itemView);
    resetAnimation(oldHolder);
    int deltaX = (int) (((float) (toX - fromX)) - prevTranslationX);
    int deltaY = (int) (((float) (toY - fromY)) - prevTranslationY);
    ViewCompat.setTranslationX(oldHolder.itemView, prevTranslationX);
    ViewCompat.setTranslationY(oldHolder.itemView, prevTranslationY);
    ViewCompat.setAlpha(oldHolder.itemView, prevAlpha);
    if (newHolder != null) {
        resetAnimation(newHolder);
        ViewCompat.setTranslationX(newHolder.itemView, (float) (-deltaX));
        ViewCompat.setTranslationY(newHolder.itemView, (float) (-deltaY));
        ViewCompat.setAlpha(newHolder.itemView, 0.0f);
    }
    this.mPendingChanges.add(new ChangeInfo(oldHolder, newHolder, fromX, fromY, toX, toY));
    return true;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:23,代碼來源:DefaultItemAnimator.java

示例5: intersectVisibleToUser

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
private boolean intersectVisibleToUser(Rect localRect) {
    if (localRect == null || localRect.isEmpty() || this.mView.getWindowVisibility() != 0) {
        return false;
    }
    ViewParent viewParent = this.mView.getParent();
    while (viewParent instanceof View) {
        View view = (View) viewParent;
        if (ViewCompat.getAlpha(view) <= 0.0f || view.getVisibility() != 0) {
            return false;
        }
        viewParent = view.getParent();
    }
    if (viewParent == null || !this.mView.getLocalVisibleRect(this.mTempVisibleRect)) {
        return false;
    }
    return localRect.intersect(this.mTempVisibleRect);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:18,代碼來源:ExploreByTouchHelper.java

示例6: 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) {
		// Don't know how to run change animations when the same view holder is re-used.
		// run a move animation to handle position changes.
		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:weiwenqiang,項目名稱:GitHub,代碼行數:29,代碼來源:FlexibleItemAnimator.java

示例7: showCheckedView

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
private void showCheckedView(boolean show)
{
    float alpha = show ? 1.0f : 0f;
    if (ViewCompat.getAlpha(mViewChecked) != alpha)
    {
        ViewCompat.setAlpha(mViewChecked, alpha);
    }
}
 
開發者ID:zj565061763,項目名稱:switchbutton,代碼行數:9,代碼來源:FSwitchButton.java

示例8: 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) {
        // Don't know how to run change animations when the same view holder is re-used.
        // run a move animation to handle position changes.
        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:MLNO,項目名稱:airgram,代碼行數:29,代碼來源:DefaultItemAnimator.java

示例9: animateChange

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
@Override
public boolean animateChange(RecyclerView.ViewHolder oldHolder, RecyclerView.ViewHolder newHolder,
                             int fromX, int fromY, int toX, int toY) {
    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.
        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:nhocga1995s,項目名稱:MyCalendar,代碼行數:29,代碼來源:BaseItemAnimator.java

示例10: onDraw

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
@Override
public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
    int visibleCount = parent.getChildCount();
    int count = state.getItemCount();
    RecyclerView.Adapter adapter = parent.getAdapter();
    int adapterCount = adapter != null ? adapter.getItemCount() : 0;

    for (int i = 0; i < visibleCount; i++) {
        View view = parent.getChildAt(i);
        int position = parent.getChildAdapterPosition(view);
        float translationX = ViewCompat.getTranslationX(view);
        float translationY = ViewCompat.getTranslationY(view);
        float alpha = ViewCompat.getAlpha(view);
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams();

        int shadows = LEFT|RIGHT;
        if(position == count - 1 && adapterCount != 0) shadows|=BOTTOM;

        drawable.setAlpha((int) (255*alpha));
        drawable.setShadow(shadows);
        drawable.setBounds(0, 0, parent.getWidth(), view.getHeight());
        int saved = canvas.save();
            canvas.translate(parent.getPaddingLeft() + translationX,
                            view.getTop() + params.topMargin + translationY);
            drawable.draw(canvas);
        canvas.restoreToCount(saved);
    }
}
 
開發者ID:zuoweitan,項目名稱:Hitalk,代碼行數:29,代碼來源:SuggestionItemDecorator.java

示例11: updateView

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
@Override
public void updateView(@NonNull View view, float position) {
    super.updateView(view, position);

    final CardView card = ((CardView)view);
    final View alphaView = card.getChildAt(1);
    final View imageView = card.getChildAt(0);

    if (position < 0) {
        final float alpha = ViewCompat.getAlpha(view);
        ViewCompat.setAlpha(view, 1f);
        ViewCompat.setAlpha(alphaView, 0.9f - alpha);
        ViewCompat.setAlpha(imageView, 0.3f + alpha);
    } else {
        ViewCompat.setAlpha(alphaView, 0f);
        ViewCompat.setAlpha(imageView, 1f);
    }

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        final CardSliderLayoutManager lm =  getLayoutManager();
        final float ratio = (float) lm.getDecoratedLeft(view) / lm.getActiveCardLeft();

        final float z;

        if (position < 0) {
            z = Z_CENTER_1 * ratio;
        } else if (position < 0.5f) {
            z = Z_CENTER_1;
        } else if (position < 1f) {
            z = Z_CENTER_2;
        } else {
            z = Z_RIGHT;
        }

        card.setCardElevation(Math.max(0, z));
    }
}
 
開發者ID:Ramotion,項目名稱:cardslider-android,代碼行數:38,代碼來源:CardsUpdater.java

示例12: onDrawOver

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
    int lastChildPosition = -1;
    int childCount = mShowLastDivider ? parent.getChildCount() : parent.getChildCount() - 1;
    for (int i = 0; i < childCount; i++) {
        View child = parent.getChildAt(i);
        int childPosition = parent.getChildAdapterPosition(child);

        if (childPosition < lastChildPosition) {
            // Avoid remaining divider when animation starts
            continue;
        }
        lastChildPosition = childPosition;

        if (ViewCompat.getAlpha(child) < 1) {
            // Avoid remaining divider when animation starts
            continue;
        }

        if (mVisibilityProvider.shouldHideDivider(childPosition, parent)) {
            continue;
        }

        Rect bounds = getDividerBound(childPosition, parent, child);
        switch (mDividerType) {
            case DRAWABLE:
                Drawable drawable = mDrawableProvider.drawableProvider(childPosition, parent);
                drawable.setBounds(bounds);
                drawable.draw(c);
                break;
            case PAINT:
                mPaint = mPaintProvider.dividerPaint(childPosition, parent);
                c.drawLine(bounds.left, bounds.top, bounds.right, bounds.bottom, mPaint);
                break;
            case COLOR:
                mPaint.setColor(mColorProvider.dividerColor(childPosition, parent));
                mPaint.setStrokeWidth(mSizeProvider.dividerSize(childPosition, parent));
                c.drawLine(bounds.left, bounds.top, bounds.right, bounds.bottom, mPaint);
                break;
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:43,代碼來源:FlexibleDividerDecoration.java

示例13: onDraw

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
    int lastChildPosition = -1;
    int childCount = mShowLastDivider ? parent.getChildCount() : parent.getChildCount() - 1;
    for (int i = 0; i < childCount; i++) {
        View child = parent.getChildAt(i);
        int childPosition = parent.getChildAdapterPosition(child);

        if (childPosition < lastChildPosition) {
            // Avoid remaining divider when animation starts
            continue;
        }
        lastChildPosition = childPosition;

        if (ViewCompat.getAlpha(child) < 1) {
            // Avoid remaining divider when animation starts
            continue;
        }

        if (mVisibilityProvider.shouldHideDivider(childPosition, parent)) {
            continue;
        }

        Rect bounds = getDividerBound(childPosition, parent, child);
        switch (mDividerType) {
            case DRAWABLE:
                Drawable drawable = mDrawableProvider.drawableProvider(childPosition, parent);
                drawable.setBounds(bounds);
                drawable.draw(c);
                break;
            case PAINT:
                mPaint = mPaintProvider.dividerPaint(childPosition, parent);
                c.drawLine(bounds.left, bounds.top, bounds.right, bounds.bottom, mPaint);
                break;
            case COLOR:
                mPaint.setColor(mColorProvider.dividerColor(childPosition, parent));
                mPaint.setStrokeWidth(mSizeProvider.dividerSize(childPosition, parent));
                c.drawLine(bounds.left, bounds.top, bounds.right, bounds.bottom, mPaint);
                break;
        }
    }
}
 
開發者ID:Jusenr,項目名稱:AppFirCloud,代碼行數:43,代碼來源:FlexibleDividerDecoration.java

示例14: 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


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