本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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();
}
示例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);
}
}
示例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("释放刷新");
}
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
示例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));
}
示例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();
}
}
示例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;
}