Example usage for android.view View setAlpha

List of usage examples for android.view View setAlpha

Introduction

In this page you can find the example usage for android.view View setAlpha.

Prototype

public void setAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha) 

Source Link

Document

Sets the opacity of the view to a value from 0 to 1, where 0 means the view is completely transparent and 1 means the view is completely opaque.

Usage

From source file:com.hannesdorfmann.home.HomeActivity.java

private void popAnim(View v, int startDelay, int duration) {
    if (v != null) {
        v.setAlpha(0f);
        v.setScaleX(0f);//from   w  w  w  .j  a  v  a2 s. c  om
        v.setScaleY(0f);

        v.animate().alpha(1f).scaleX(1f).scaleY(1f).setStartDelay(startDelay).setDuration(duration)
                .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.overshoot));
    }
}

From source file:com.gabm.fancyplaces.ui.MainWindow.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    menu.clear();//from  w w w  .  j  a v a  2  s.  c  om

    getMenuInflater().inflate(curState.curMenu, menu);

    Toolbar toolbar = (Toolbar) findViewById(R.id.main_window_toolbar);
    if (curState.curMenu == R.menu.menu_main_window_multi_select) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        toolbar.setTitle(getString(R.string.main_multi_selection_title));
        toolbar.setBackgroundColor(getResources().getColor(R.color.ColorPrimaryDark));
        int noOfChild = toolbar.getChildCount();
        View view;

        // animate toolbar elements
        for (int i = 1; i < noOfChild; i++) {
            view = toolbar.getChildAt(i);
            view.setAlpha(0);
            view.setScaleY(0);
            view.setPivotY((float) 0.5 * view.getHeight());
            view.animate().setDuration(200).scaleY(1).alpha(1);
        }

    } else if (curState.curMenu == R.menu.menu_main_window) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        setDefaultTitle();
        toolbar.setBackgroundColor(getResources().getColor(R.color.ColorPrimary));
    }

    return super.onPrepareOptionsMenu(menu);
}

From source file:im.ene.lab.attiq.ui.activities.HomeActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case REQUEST_CODE_SEARCH:
        // reset the search icon which we hid
        View searchMenuView = mToolBar.findViewById(R.id.action_search);
        if (searchMenuView != null) {
            searchMenuView.setAlpha(1.f);
        }//w  w  w . ja  v a  2 s.co m
        break;
    case REQUEST_CODE_LOGIN:
        if (resultCode == RESULT_OK && data != null) {
            String callback = data.getStringExtra(EXTRA_AUTH_CALLBACK);
            Uri callbackUri = Uri.parse(callback);
            final String code = callbackUri.getQueryParameter("code");
            ApiClient.accessToken(code).enqueue(mOnTokenCallback);
        }
        break;
    default:
        break;
    }
}

From source file:edward.com.recyclerview.BaseItemAnimator.java

void reset(View v) {
    v.setAlpha(1);
    v.setScaleY(1);//from w w  w. j  a  va  2  s .c o m
    v.setScaleX(1);
    v.setTranslationY(0);
    v.setTranslationX(0);
    v.setRotation(0);
    v.setRotationY(0);
    v.setRotationX(0);
    v.setPivotX(v.getMeasuredWidth() / 2);
    v.setPivotY(v.getMeasuredHeight() / 2);
    v.animate().setInterpolator(null);
}

From source file:com.greatspeeches.helper.PagerSlidingTabStrip.java

private void updateTabStyles() {

    for (int i = 0; i < tabCount; i++) {

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);
        v.setAlpha(25f);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);

            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }//w  w w  . j a v a 2s .co m
            }
        }
    }

}

From source file:android.support.transition.FadePort.java

@Override
public Animator onAppear(ViewGroup sceneRoot, TransitionValues startValues, int startVisibility,
        TransitionValues endValues, int endVisibility) {
    if ((mFadingMode & IN) != IN || endValues == null) {
        return null;
    }//from w  ww  . j a va 2  s  . c  om
    final View endView = endValues.view;
    if (DBG) {
        View startView = (startValues != null) ? startValues.view : null;
        Log.d(LOG_TAG, "Fade.onAppear: startView, startVis, endView, endVis = " + startView + ", "
                + startVisibility + ", " + endView + ", " + endVisibility);
    }
    endView.setAlpha(0);
    TransitionListener transitionListener = new TransitionListenerAdapter() {
        boolean mCanceled = false;

        float mPausedAlpha;

        @Override
        public void onTransitionCancel(TransitionPort transition) {
            endView.setAlpha(1);
            mCanceled = true;
        }

        @Override
        public void onTransitionEnd(TransitionPort transition) {
            if (!mCanceled) {
                endView.setAlpha(1);
            }
        }

        @Override
        public void onTransitionPause(TransitionPort transition) {
            mPausedAlpha = endView.getAlpha();
            endView.setAlpha(1);
        }

        @Override
        public void onTransitionResume(TransitionPort transition) {
            endView.setAlpha(mPausedAlpha);
        }
    };
    addListener(transitionListener);
    return createAnimation(endView, 0, 1, null);
}

From source file:net.huannguyen.conductorexample.transition.DetailPopAnimChangeHandler.java

@NonNull
@Override/*from   w w w. j  a  va  2s  . co  m*/
protected Animator getAnimator(@NonNull ViewGroup container, @Nullable View from, @Nullable View to,
        boolean isPush, boolean toAddedToContainer) {

    // Make sure the from view is a CountryDetailView
    if (from == null || !(from instanceof CountryDetailView))
        throw new IllegalArgumentException("The from view must be a CountryDetailView");

    if (to == null)
        throw new IllegalArgumentException("The to view must not be null");

    final CountryDetailView detailView = (CountryDetailView) from;

    AnimatorSet animatorSet = new AnimatorSet();

    // Set the to View's alpha to 0 to hide it at the beginning.
    to.setAlpha(0);

    // Scale down to hide the fab button
    PropertyValuesHolder fabScaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, 0);
    PropertyValuesHolder fabScaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0);
    Animator hideFabButtonAnimator = ObjectAnimator.ofPropertyValuesHolder(detailView.favouriteFab, fabScaleX,
            fabScaleY);

    // Slide up the flag
    Animator flagAnimator = ObjectAnimator.ofFloat(detailView.flagView, View.TRANSLATION_Y, 0,
            -detailView.flagView.getHeight());

    // Slide down the details
    Animator detailAnimator = ObjectAnimator.ofFloat(detailView.detailGroup, View.TRANSLATION_Y, 0,
            detailView.detailGroup.getHeight());

    // Show the new view
    Animator showToViewAnimator = ObjectAnimator.ofFloat(to, View.ALPHA, 0, 1);

    animatorSet.playTogether(hideFabButtonAnimator, flagAnimator, detailAnimator, showToViewAnimator);
    animatorSet.setDuration(300);
    animatorSet.setInterpolator(new FastOutLinearInInterpolator());

    animatorSet.start();

    return animatorSet;
}

From source file:com.taobao.weex.ui.component.WXSliderNeighbor.java

private void updateScaleAndAlpha(View view, float alpha, float scale) {
    if (null == view) {
        return;/*from w  w w  .ja  v a  2s.com*/
    }
    if (alpha >= 0 && view.getAlpha() != alpha) {
        view.setAlpha(alpha);
    }
    if (scale >= 0 && view.getScaleX() != scale) {
        view.setScaleX(scale);
        view.setScaleY(scale);
    }
}

From source file:com.sixbynine.infosessions.ui.PagerSlidingTabStrip.java

public void notifyDataSetChanged() {

    tabsContainer.removeAllViews();//from  ww  w.  j  a v  a2s .  c  o m

    tabCount = pager.getAdapter().getCount();

    for (int i = 0; i < tabCount; i++) {

        if (pager.getAdapter() instanceof IconTabProvider) {
            addIconTab(i, ((IconTabProvider) pager.getAdapter()).getPageIconResId(i));
        } else {
            addTextTab(i, pager.getAdapter().getPageTitle(i).toString());
        }

    }

    updateTabStyles();

    getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

        @SuppressWarnings("deprecation")
        @SuppressLint("NewApi")
        @Override
        public void onGlobalLayout() {

            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
                getViewTreeObserver().removeGlobalOnLayoutListener(this);
            } else {
                getViewTreeObserver().removeOnGlobalLayoutListener(this);
            }

            currentPosition = pager.getCurrentItem();
            scrollToChild(currentPosition, 0);
            for (int i = 0; i < tabCount; i++) {
                View v = tabsContainer.getChildAt(i);
                if (i == currentPosition) {
                    v.setAlpha(1f);
                } else {
                    v.setAlpha(0.6f);
                }
            }
        }
    });

}

From source file:android.support.v17.leanback.app.OnboardingSupportFragment.java

private void startEnterAnimation() {
    mEnterTransitionFinished = true;/*from  ww w  .  j  a  va  2 s  .  com*/
    initializeViews(getView());
    List<Animator> animators = new ArrayList<>();
    Animator animator = AnimatorInflater.loadAnimator(getActivity(),
            R.animator.lb_onboarding_page_indicator_enter);
    animator.setTarget(getPageCount() <= 1 ? mStartButton : mPageIndicator);
    animators.add(animator);
    // Header title
    View view = getActivity().findViewById(R.id.title);
    view.setAlpha(0);
    animator = AnimatorInflater.loadAnimator(getActivity(), R.animator.lb_onboarding_title_enter);
    animator.setStartDelay(START_DELAY_TITLE_MS);
    animator.setTarget(view);
    animators.add(animator);
    // Header description
    view = getActivity().findViewById(R.id.description);
    view.setAlpha(0);
    animator = AnimatorInflater.loadAnimator(getActivity(), R.animator.lb_onboarding_description_enter);
    animator.setStartDelay(START_DELAY_DESCRIPTION_MS);
    animator.setTarget(view);
    animators.add(animator);
    // Customized animation by the inherited class.
    Animator customAnimator = onCreateEnterAnimation();
    if (customAnimator != null) {
        animators.add(customAnimator);
    }
    mAnimator = new AnimatorSet();
    mAnimator.playTogether(animators);
    mAnimator.start();
    // Search focus and give the focus to the appropriate child which has become visible.
    getView().requestFocus();
}