Java Code Examples for android.view.View.setAlpha()

The following are Jave code examples for showing how to use setAlpha() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: mobile-store   File: ScreenShotsActivity.java   View Source Code Vote up 7 votes
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);
    }
}
 
Example 2
Project: ChromeLikeTabSwitcher   File: PhoneTabSwitcherLayout.java   View Source Code Vote up 7 votes
/**
 * 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);
        }

    };
}
 
Example 3
Project: ChromeLikeTabSwitcher   File: PhoneTabSwitcherLayout.java   View Source Code Vote up 7 votes
/**
 * 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);
        }

    };
}
 
Example 4
Project: Pilem   File: MovieDetailFragment.java   View Source Code Vote up 7 votes
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);
}
 
Example 5
Project: boohee_v5.6   File: ZoomOutSlideTransformer.java   View Source Code Vote up 7 votes
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);
    }
}
 
Example 6
Project: AndroidViewPagerRxJava   File: ZoomOutTranformer.java   View Source Code Vote up 6 votes
@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);
	}
}
 
Example 7
Project: PageTransformerHelp   File: ZoomOutTranformer.java   View Source Code Vote up 6 votes
@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);
	}
}
 
Example 8
Project: AndroidBasicLibs   File: FlipVerticalTransformer.java   View Source Code Vote up 6 votes
@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);
}
 
Example 9
Project: MNImageBrowser   File: ZoomInTransformer.java   View Source Code Vote up 6 votes
@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));
}
 
Example 10
Project: garras   File: PageAnimator.java   View Source Code Vote up 6 votes
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);
}
 
Example 11
Project: Appmatic-Android   File: DepthPageTransformer.java   View Source Code Vote up 6 votes
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);
    }
}
 
Example 12
Project: decoy   File: FadeInOutPageTransformer.java   View Source Code Vote up 6 votes
@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);
    }
}
 
Example 13
Project: NeoTerm   File: PhoneTabSwitcherLayout.java   View Source Code Vote up 6 votes
/**
 * 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;
        }

    };
}
 
Example 14
Project: QMUI_Android   File: QMUIAlphaViewHelper.java   View Source Code Vote up 6 votes
public void onPressedChanged(View target, boolean pressed) {
    if (mTarget.isEnabled()) {
        mTarget.setAlpha(mChangeAlphaWhenPress && pressed && target.isClickable()? mPressedAlpha : mNormalAlpha);
    } else {
        if (mChangeAlphaWhenDisable) {
            target.setAlpha(mDisabledAlpha);
        }
    }
}
 
Example 15
Project: BannerView   File: FlipVerticalTransformer.java   View Source Code Vote up 6 votes
@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);
}
 
Example 16
Project: GeekZone   File: DepthPageTransformer.java   View Source Code Vote up 6 votes
@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);
	}
}
 
Example 17
Project: GxIconAndroid   File: SimplePageTransformer.java   View Source Code Vote up 6 votes
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);
    }
}
 
Example 18
Project: Rx2Animations   File: RxAnimations.java   View Source Code Vote up 5 votes
public static void set(final View view, final float x, final float y, final float alpha) {
    view.setAlpha(alpha);
    view.setX(x);
    view.setY(y);
}
 
Example 19
Project: QuickActionView   File: PopAnimator.java   View Source Code Vote up 5 votes
@Override
public void animateScrimIn(View scrim) {
    scrim.setAlpha(0f);
    scrim.animate().alpha(1f).setDuration(200);
}
 
Example 20
Project: ViewTooltip   File: ViewTooltip.java   View Source Code Vote up 5 votes
@Override
public void animateEnter(View view, Animator.AnimatorListener animatorListener) {
    view.setAlpha(0);
    view.animate().alpha(1).setDuration(fadeDuration).setListener(animatorListener);
}