本文整理汇总了Java中android.view.View.setAlpha方法的典型用法代码示例。如果您正苦于以下问题:Java View.setAlpha方法的具体用法?Java View.setAlpha怎么用?Java View.setAlpha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.setAlpha方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transformPage
import android.view.View; //导入方法依赖的package包/类
public void transformPage(View view, float position) {
int pageWidth = view.getWidth();
if (position <= 0) {
// use the default slide transition when moving to the left page
view.setAlpha(1);
view.setTranslationX(0);
} else if (position <= 1) {
// fade the page out.
view.setAlpha(1 - position);
// add parallax effect
view.setTranslationX(pageWidth * -position / 2);
} else {
// this page is way off-screen to the right.
view.setAlpha(0);
}
}
示例2: createAddSelectedTabLayoutListener
import android.view.View; //导入方法依赖的package包/类
/**
* Creates and returns a layout listener, which allows to show a tab as the currently selected
* one, once it view has been inflated.
*
* @param item
* The item, which corresponds to the tab, which has been added, as an instance of the
* class {@link AbstractItem}. The item may not be null
* @return The listener, which has been created, as an instance of the type {@link
* OnGlobalLayoutListener}. The listener may not be null
*/
@NonNull
private OnGlobalLayoutListener createAddSelectedTabLayoutListener(
@NonNull final AbstractItem item) {
return new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
View view = item.getView();
FrameLayout.LayoutParams layoutParams =
(FrameLayout.LayoutParams) view.getLayoutParams();
view.setAlpha(1f);
getArithmetics().setPivot(Axis.DRAGGING_AXIS, item,
getArithmetics().getPivot(Axis.DRAGGING_AXIS, item, DragState.NONE));
getArithmetics().setPivot(Axis.ORTHOGONAL_AXIS, item,
getArithmetics().getPivot(Axis.ORTHOGONAL_AXIS, item, DragState.NONE));
view.setX(layoutParams.leftMargin);
view.setY(layoutParams.topMargin);
getArithmetics().setScale(Axis.DRAGGING_AXIS, item, 1);
getArithmetics().setScale(Axis.ORTHOGONAL_AXIS, item, 1);
}
};
}
示例3: createRevealLayoutListener
import android.view.View; //导入方法依赖的package包/类
/**
* Creates and returns a layout listener, which allows to start a reveal animation to add a tab,
* once its view has been inflated.
*
* @param item
* The item, which corresponds to the tab, which should be added, as an instance of the
* class {@link AbstractItem}. The item may not be null
* @param revealAnimation
* The reveal animation, which should be started, as an instance of the class {@link
* RevealAnimation}. The reveal animation may not be null
* @return The listener, which has been created, as an instance of the type {@link
* OnGlobalLayoutListener}. The listener may not be null
*/
@NonNull
private OnGlobalLayoutListener createRevealLayoutListener(@NonNull final AbstractItem item,
@NonNull final RevealAnimation revealAnimation) {
return new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
View view = item.getView();
float x = revealAnimation.getX();
float y = revealAnimation.getY() + tabTitleContainerHeight;
FrameLayout.LayoutParams layoutParams =
(FrameLayout.LayoutParams) view.getLayoutParams();
view.setAlpha(1f);
getArithmetics().setPivot(Axis.X_AXIS, item, x);
getArithmetics().setPivot(Axis.Y_AXIS, item, y);
view.setX(layoutParams.leftMargin);
view.setY(layoutParams.topMargin);
getArithmetics().setScale(Axis.DRAGGING_AXIS, item, 0);
getArithmetics().setScale(Axis.ORTHOGONAL_AXIS, item, 0);
animateReveal(item, revealAnimation);
}
};
}
示例4: setUpBackdrop
import android.view.View; //导入方法依赖的package包/类
private void setUpBackdrop(View view) {
Context context = view.getContext();
ImageView imgBackdrop = (ImageView) view.findViewById(R.id.iv_movie_backdrop);
View viewOverlay = view.findViewById(R.id.view_backdrop_overlay);
TextView tvTitle = (TextView) view.findViewById(R.id.tv_movie_detail_title);
Picasso.with(context)
.load(R.mipmap.civil_war_backdrop)
.transform(new GrayscaleTransformation(Picasso.with(context)))
.into(imgBackdrop);
imgBackdrop.setContentDescription(mTitle);
viewOverlay.setAlpha((float) 0.8);
}
示例5: onTransform
import android.view.View; //导入方法依赖的package包/类
protected void onTransform(View view, float position) {
if (position >= -1.0f || position <= 1.0f) {
float height = (float) view.getHeight();
float scaleFactor = Math.max(MIN_SCALE, 1.0f - Math.abs(position));
float vertMargin = ((1.0f - scaleFactor) * height) / 2.0f;
float horzMargin = (((float) view.getWidth()) * (1.0f - scaleFactor)) / 2.0f;
view.setPivotY(MIN_ALPHA * height);
if (position < 0.0f) {
view.setTranslationX(horzMargin - (vertMargin / 2.0f));
} else {
view.setTranslationX((-horzMargin) + (vertMargin / 2.0f));
}
view.setScaleX(scaleFactor);
view.setScaleY(scaleFactor);
view.setAlpha((((scaleFactor - MIN_SCALE) / 0.14999998f) * MIN_ALPHA) + MIN_ALPHA);
}
}
示例6: onTransform
import android.view.View; //导入方法依赖的package包/类
@Override
protected void onTransform(View view, float position) {
final float scale = 1f + Math.abs(position);
view.setScaleX(scale);
view.setScaleY(scale);
view.setPivotX(view.getWidth() * 0.5f);
view.setPivotY(view.getHeight() * 0.5f);
view.setAlpha(position < -1f || position > 1f ? 0f : 1f - (scale - 1f));
if(position == -1){
view.setTranslationX(view.getWidth() * -1);
}
}
示例7: onTransform
import android.view.View; //导入方法依赖的package包/类
@Override
protected void onTransform(View view, float position) {
final float rotation = -180f * position;
view.setAlpha(rotation > 90f || rotation < -90f ? 0f : 1f);
view.setPivotX(view.getWidth() * 0.5f);
view.setPivotY(view.getHeight() * 0.5f);
view.setRotationX(rotation);
}
示例8: onTransform
import android.view.View; //导入方法依赖的package包/类
@Override
protected void onTransform(View view, float position) {
final float scale = position < 0 ? position + 1f : Math.abs(1f - position);
view.setScaleX(scale);
view.setScaleY(scale);
view.setPivotX(view.getWidth() * 0.5f);
view.setPivotY(view.getHeight() * 0.5f);
view.setAlpha(position < -1f || position > 1f ? 0f : 1f - (scale - 1f));
}
示例9: transformUnderlyingPage
import android.view.View; //导入方法依赖的package包/类
protected void transformUnderlyingPage(View page, float position, boolean enter) {
page.setAlpha(1);
page.setScaleX(1);
page.setScaleY(1);
page.setTranslationX(0);
page.setTranslationY(0);
// Avoid overdraw
page.setVisibility(View.INVISIBLE);
}
示例10: transformPage
import android.view.View; //导入方法依赖的package包/类
public void transformPage(View view, float position) {
int pageWidth = view.getWidth();
if (position < -1) { // [-Infinity,-1)
// This page is way off-screen to the left.
view.setAlpha(0);
} else if (position <= 0) { // [-1,0]
// Use the default slide transition when moving to the left page
view.setAlpha(1);
view.setTranslationX(0);
view.setScaleX(1);
view.setScaleY(1);
} else if (position <= 1) { // (0,1]
// Fade the page out.
view.setAlpha(1 - position);
// Counteract the default slide transition
view.setTranslationX(pageWidth * -position);
// Scale the page down (between MIN_SCALE and 1)
float scaleFactor = MIN_SCALE
+ (1 - MIN_SCALE) * (1 - Math.abs(position));
view.setScaleX(scaleFactor);
view.setScaleY(scaleFactor);
} else { // (1,+Infinity]
// This page is way off-screen to the right.
view.setAlpha(0);
}
}
示例11: transformPage
import android.view.View; //导入方法依赖的package包/类
@SuppressLint("NewApi")
@Override
public void transformPage(View page, float position) {
if (position < -1) {//页码完全不可见
page.setAlpha(0);
} else if (position < 0) {
page.setAlpha(1 + position);
} else if (position < 1) {
page.setAlpha(1 - position);
} else {
page.setAlpha(0);
}
}
示例12: createHideSwitcherAnimationListener
import android.view.View; //导入方法依赖的package包/类
/**
* Creates and returns an animation listener, which allows to inflate or remove the views, which
* are used to visualize tabs, when an animation, which is used to hide the tab switcher,
* has been finished.
*
* @return The animation listener, which has been created, as an instance of the type {@link
* AnimatorListener}. The listener may not be null
*/
@NonNull
private AnimatorListener createHideSwitcherAnimationListener() {
return new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(final Animator animation) {
super.onAnimationEnd(animation);
AbstractTabItemIterator iterator =
new TabItemIterator.Builder(getTabSwitcher(), viewRecycler).create();
TabItem tabItem;
while ((tabItem = iterator.next()) != null) {
if (tabItem.getTab() == getModel().getSelectedTab()) {
Pair<View, Boolean> pair = viewRecycler.inflate(tabItem);
View view = pair.first;
FrameLayout.LayoutParams layoutParams =
(FrameLayout.LayoutParams) view.getLayoutParams();
view.setAlpha(1f);
getArithmetics().setScale(Axis.DRAGGING_AXIS, view, 1);
getArithmetics().setScale(Axis.ORTHOGONAL_AXIS, view, 1);
view.setX(layoutParams.leftMargin);
view.setY(layoutParams.topMargin);
} else {
viewRecycler.remove(tabItem);
}
}
viewRecycler.clearCache();
recyclerAdapter.clearCachedPreviews();
tabViewBottomMargin = -1;
}
};
}
示例13: onPressedChanged
import android.view.View; //导入方法依赖的package包/类
public void onPressedChanged(View target, boolean pressed) {
if (mTarget.isEnabled()) {
mTarget.setAlpha(mChangeAlphaWhenPress && pressed && target.isClickable()? mPressedAlpha : mNormalAlpha);
} else {
if (mChangeAlphaWhenDisable) {
target.setAlpha(mDisabledAlpha);
}
}
}
示例14: onTransform
import android.view.View; //导入方法依赖的package包/类
@Override
protected void onTransform(View view, float position) {
if (position <= 0f) {
view.setTranslationX(0f);
view.setScaleX(1f);
view.setScaleY(1f);
} else if (position <= 1f) {
final float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
view.setAlpha(1 - position);
view.setPivotY(0.5f * view.getHeight());
view.setTranslationX(view.getWidth() * -position);
view.setScaleX(scaleFactor);
view.setScaleY(scaleFactor);
}
}
示例15: transformPageZoomOut
import android.view.View; //导入方法依赖的package包/类
private void transformPageZoomOut(View view, float position) {
final float MIN_SCALE = 0.85f;
final float MIN_ALPHA = 0.5f;
int pageWidth = view.getWidth();
int pageHeight = view.getHeight();
if (position < -1) { // [-Infinity,-1)
// This page is way off-screen to the left.
view.setAlpha(0);
} else if (position <= 1) { // [-1,1]
// Modify the default slide transition to shrink the page as well
float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
float verMargin = pageHeight * (1 - scaleFactor) / 2;
float horzMargin = pageWidth * (1 - scaleFactor) / 2;
if (position < 0) {
view.setTranslationX(horzMargin - verMargin / 2);
} else {
view.setTranslationX(-horzMargin + verMargin / 2);
}
// Scale the page down (between MIN_SCALE and 1)
view.setScaleX(scaleFactor);
view.setScaleY(scaleFactor);
// Fade the page relative to its size.
view.setAlpha(MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA));
} else { // (1,+Infinity]
// This page is way off-screen to the right.
view.setAlpha(0);
}
}