当前位置: 首页>>代码示例>>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;未经允许,请勿转载。