Example usage for android.view.animation AlphaAnimation AlphaAnimation

List of usage examples for android.view.animation AlphaAnimation AlphaAnimation

Introduction

In this page you can find the example usage for android.view.animation AlphaAnimation AlphaAnimation.

Prototype

public AlphaAnimation(float fromAlpha, float toAlpha) 

Source Link

Document

Constructor to use when building an AlphaAnimation from code

Usage

From source file:me.tylerbwong.pokebase.gui.activities.PokemonProfileActivity.java

public static void startAlphaAnimation(View view, long duration, int visibility) {
    AlphaAnimation alphaAnimation = (visibility == View.VISIBLE) ? new AlphaAnimation(0f, 1f)
            : new AlphaAnimation(1f, 0f);

    alphaAnimation.setDuration(duration);
    alphaAnimation.setFillAfter(true);/*from ww w .jav  a2  s .c o m*/
    view.startAnimation(alphaAnimation);
}

From source file:org.kiwix.kiwixmobile.ZimFileSelectActivity.java

private void setAlpha(boolean transparent) {

    float viewTransparency = transparent ? 0.4F : 1F;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        mZimFileList.setAlpha(viewTransparency);
    } else {//from  w  ww .j a  v a 2 s. com
        AlphaAnimation alpha = new AlphaAnimation(viewTransparency, viewTransparency);
        alpha.setDuration(0);
        alpha.setFillAfter(true);
        mZimFileList.startAnimation(alpha);
    }
}

From source file:com.cairoconfessions.MainActivity.java

public View addConfession(String confess, String desc) {
    final ViewGroup confession = (ViewGroup) LayoutInflater.from(this)
            .inflate(R.layout.confession_list_item_example, null);
    final TextView newConfess = (TextView) confession.findViewById(R.id.text_main);
    newConfess.setText(confess);//from ww  w . j  a v a2s.c o  m
    final float scale = getResources().getDisplayMetrics().density;
    if (!desc.equals("")) {
        confession.setContentDescription(desc);
        if (desc.equals("Love"))
            newConfess.setBackgroundResource(R.color.love);
        if (desc.equals("Pain"))
            newConfess.setBackgroundResource(R.color.pain);
        if (desc.equals("Guilt"))
            newConfess.setBackgroundResource(R.color.guilt);
        if (desc.equals("Fantasy"))
            newConfess.setBackgroundResource(R.color.fantasy);
        if (desc.equals("Dream"))
            newConfess.setBackgroundResource(R.color.dream);
    } else {
        switch ((new Random().nextInt(5)) % 5) {
        case 0:
            newConfess.setBackgroundResource(R.color.love);
            ((TextView) confession.findViewById(R.id.confess_loc)).setText("Riyadh");
            confession.setContentDescription("Love");
            break;
        case 1:
            newConfess.setBackgroundResource(R.color.pain);
            ((TextView) confession.findViewById(R.id.confess_loc)).setText("Cairo");
            confession.setContentDescription("Pain");
            break;
        case 2:
            newConfess.setBackgroundResource(R.color.guilt);
            ((TextView) confession.findViewById(R.id.confess_loc)).setText("New York");
            confession.setContentDescription("Guilt");
            break;
        case 3:
            newConfess.setBackgroundResource(R.color.fantasy);
            ((TextView) confession.findViewById(R.id.confess_loc)).setText("New York");
            confession.setContentDescription("Fantasy");
            break;
        case 4:
            newConfess.setBackgroundResource(R.color.dream);
            ((TextView) confession.findViewById(R.id.confess_loc)).setText("Riyadh");
            confession.setContentDescription("Dream");
            break;
        }
    }
    switch ((new Random().nextInt(3)) % 3) {
    case 0:
        ((TextView) confession.findViewById(R.id.confess_loc)).setText("Riyadh");
        break;
    case 1:
        ((TextView) confession.findViewById(R.id.confess_loc)).setText("Cairo");
        break;
    case 2:
        ((TextView) confession.findViewById(R.id.confess_loc)).setText("New York");
        break;
    }
    Animation fadeIn = new AlphaAnimation(0, 1);
    fadeIn.setDuration(1000);
    confession.setAnimation(fadeIn);
    confession.getChildAt(0).setPadding((int) (scale * 1.5 + 0.5f), (int) (scale * 1.5 + 0.5f),
            (int) (scale * 1.5 + 0.5f), (int) (scale * 1.5 + 0.5f));
    confession.getChildAt(0).setBackgroundResource(R.drawable.border);
    mPager.setCurrentItem(1);
    if (!desc.equals("")) {
        ((ScrollView) findViewById(R.id.feed)).fullScroll(ScrollView.FOCUS_UP);
        ((LinearLayout) findViewById(R.id.confession_list)).addView(confession, 0);
    } else {
        new Timer().schedule(new TimerTask() {
            @Override
            public void run() {

                ((ScrollView) findViewById(R.id.feed)).fullScroll(ScrollView.FOCUS_UP);
                ((LinearLayout) findViewById(R.id.confession_list)).post(new Runnable() {

                    public void run() {
                        ((LinearLayout) findViewById(R.id.confession_list)).addView(confession, 0);
                    }
                });
            }
        }, 1000);
    }
    return confession;

}

From source file:git.egatuts.nxtremotecontroller.fragment.OnlineControllerFragment.java

public AlphaAnimation getHideAnimation(final View view0, final View view1, final long time) {
    AlphaAnimation hide = new AlphaAnimation(1.0f, 0.0f);
    hide.setDuration(time);//from w w  w  . j  a  v a2s  .  co m
    hide.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            view0.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            view0.setVisibility(View.GONE);
            view1.startAnimation(getShowAnimation(view1, time));
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    return hide;
}

From source file:com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView: ");
    if (getShowsDialog()) {
        getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    }/* ww  w . ja v  a 2  s  .c  o m*/

    View view = inflater.inflate(R.layout.calendar_date_picker_dialog, container, false);

    mSelectedDateLayout = (LinearLayout) view.findViewById(R.id.day_picker_selected_date_layout);
    mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header);
    mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day);
    mMonthAndDayView.setOnClickListener(this);
    mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month);
    mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day);
    mYearView = (TextView) view.findViewById(R.id.date_picker_year);
    mYearView.setOnClickListener(this);

    int listPosition = -1;
    int listPositionOffset = 0;
    int currentView = MONTH_AND_DAY_VIEW;
    if (savedInstanceState != null) {
        mWeekStart = savedInstanceState.getInt(KEY_WEEK_START);
        mMinDate = new CalendarDay(savedInstanceState.getLong(KEY_DATE_START));
        mMaxDate = new CalendarDay(savedInstanceState.getLong(KEY_DATE_END));
        currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW);
        listPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
        listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET);
        mStyleResId = savedInstanceState.getInt(KEY_THEME);
        mDisabledDays = savedInstanceState.getSparseParcelableArray(KEY_DISABLED_DAYS);
    }

    final Activity activity = getActivity();
    mDayPickerView = new SimpleDayPickerView(activity, this);
    mYearPickerView = new YearPickerView(activity, this);

    Resources res = getResources();
    TypedArray themeColors = getActivity().obtainStyledAttributes(mStyleResId,
            R.styleable.BetterPickersDialogs);
    mDayPickerDescription = res.getString(R.string.day_picker_description);
    mSelectDay = res.getString(R.string.select_day);
    mYearPickerDescription = res.getString(R.string.year_picker_description);
    mSelectYear = res.getString(R.string.select_year);

    int headerBackgroundColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderBackgroundColor,
            ContextCompat.getColor(getActivity(), R.color.bpWhite));
    int preHeaderBackgroundColor = themeColors.getColor(
            R.styleable.BetterPickersDialogs_bpPreHeaderBackgroundColor,
            ContextCompat.getColor(getActivity(), R.color.bpWhite));
    int bodyBgColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpBodyBackgroundColor,
            ContextCompat.getColor(getActivity(), R.color.bpWhite));
    int buttonBgColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpButtonsBackgroundColor,
            ContextCompat.getColor(getActivity(), R.color.bpWhite));
    int buttonTextColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpButtonsTextColor,
            ContextCompat.getColor(getActivity(), R.color.bpBlue));
    mSelectedColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderSelectedTextColor,
            ContextCompat.getColor(getActivity(), R.color.bpWhite));
    mUnselectedColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderUnselectedTextColor,
            ContextCompat.getColor(getActivity(), R.color.radial_gray_light));

    mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.animator);
    mAnimator.addView(mDayPickerView);
    mAnimator.addView(mYearPickerView);
    mAnimator.setDateMillis(mCalendar.getTimeInMillis());
    // TODO: Replace with animation decided upon by the design team.
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(ANIMATION_DURATION);
    mAnimator.setInAnimation(animation);
    // TODO: Replace with animation decided upon by the design team.
    Animation animation2 = new AlphaAnimation(1.0f, 0.0f);
    animation2.setDuration(ANIMATION_DURATION);
    mAnimator.setOutAnimation(animation2);

    Button doneButton = (Button) view.findViewById(R.id.done_button);
    if (mDoneText != null) {
        doneButton.setText(mDoneText);
    }
    doneButton.setTextColor(buttonTextColor);
    doneButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryVibrate();
            if (mCallBack != null) {
                mCallBack.onDateSet(CalendarDatePickerDialogFragment.this, mCalendar.get(Calendar.YEAR),
                        mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH));
            }
            dismiss();
        }
    });
    Button cancelButton = (Button) view.findViewById(R.id.cancel_button);
    if (mCancelText != null) {
        cancelButton.setText(mCancelText);
    }
    cancelButton.setTextColor(buttonTextColor);
    cancelButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryVibrate();
            dismiss();
        }
    });
    view.findViewById(R.id.ok_cancel_buttons_layout).setBackgroundColor(buttonBgColor);

    updateDisplay(false);
    setCurrentView(currentView);

    if (listPosition != -1) {
        if (currentView == MONTH_AND_DAY_VIEW) {
            mDayPickerView.postSetSelection(listPosition);
        } else if (currentView == YEAR_VIEW) {
            mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset);
        }
    }

    mHapticFeedbackController = new HapticFeedbackController(activity);

    mDayPickerView.setTheme(themeColors);
    mYearPickerView.setTheme(themeColors);

    mSelectedDateLayout.setBackgroundColor(headerBackgroundColor);
    mYearView.setBackgroundColor(headerBackgroundColor);
    mMonthAndDayView.setBackgroundColor(headerBackgroundColor);

    if (mDayOfWeekView != null) {
        mDayOfWeekView.setBackgroundColor(preHeaderBackgroundColor);
    }
    view.setBackgroundColor(bodyBgColor);
    mYearPickerView.setBackgroundColor(bodyBgColor);
    mDayPickerView.setBackgroundColor(bodyBgColor);

    return view;
}

From source file:com.mattfred.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView: ");
    if (getShowsDialog()) {
        getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    }/*  www  .j a v a 2  s . c  o  m*/

    View view = inflater.inflate(R.layout.calendar_date_picker_dialog, null);

    mSelectedDateLayout = (LinearLayout) view.findViewById(R.id.day_picker_selected_date_layout);
    mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header);
    mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day);
    mMonthAndDayView.setOnClickListener(this);
    mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month);
    mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day);
    mYearView = (TextView) view.findViewById(R.id.date_picker_year);
    mYearView.setOnClickListener(this);

    int listPosition = -1;
    int listPositionOffset = 0;
    int currentView = MONTH_AND_DAY_VIEW;
    if (savedInstanceState != null) {
        mWeekStart = savedInstanceState.getInt(KEY_WEEK_START);
        mMinDate = new CalendarDay(savedInstanceState.getLong(KEY_DATE_START));
        mMaxDate = new CalendarDay(savedInstanceState.getLong(KEY_DATE_END));
        currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW);
        listPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
        listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET);
        mStyleResId = savedInstanceState.getInt(KEY_THEME);
        mDisabledDays = savedInstanceState.getSparseParcelableArray(KEY_DISABLED_DAYS);
    }

    final Activity activity = getActivity();
    mDayPickerView = new SimpleDayPickerView(activity, this);
    mYearPickerView = new YearPickerView(activity, this);

    Resources res = getResources();
    TypedArray themeColors = getActivity().obtainStyledAttributes(mStyleResId, R.styleable.BetterPickersDialog);
    mDayPickerDescription = res.getString(R.string.day_picker_description);
    mSelectDay = res.getString(R.string.select_day);
    mYearPickerDescription = res.getString(R.string.year_picker_description);
    mSelectYear = res.getString(R.string.select_year);
    mSelectedColor = themeColors.getColor(R.styleable.BetterPickersDialog_bpAccentColor, R.color.bpBlue);
    mUnselectedColor = themeColors.getColor(R.styleable.BetterPickersDialog_bpMainTextColor,
            R.color.numbers_text_color);

    mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.animator);
    mAnimator.addView(mDayPickerView);
    mAnimator.addView(mYearPickerView);
    mAnimator.setDateMillis(mCalendar.getTimeInMillis());
    // TODO: Replace with animation decided upon by the design team.
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(ANIMATION_DURATION);
    mAnimator.setInAnimation(animation);
    // TODO: Replace with animation decided upon by the design team.
    Animation animation2 = new AlphaAnimation(1.0f, 0.0f);
    animation2.setDuration(ANIMATION_DURATION);
    mAnimator.setOutAnimation(animation2);

    Button doneButton = (Button) view.findViewById(R.id.done_button);
    doneButton.setTextColor(mSelectedColor);
    doneButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            onOkClick();
        }
    });
    Button cancelButton = (Button) view.findViewById(R.id.cancel_button);
    cancelButton.setTextColor(mSelectedColor);
    cancelButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryVibrate();
            dismiss();
        }
    });

    updateDisplay(false);
    setCurrentView(currentView);

    if (listPosition != -1) {
        if (currentView == MONTH_AND_DAY_VIEW) {
            mDayPickerView.postSetSelection(listPosition);
        } else if (currentView == YEAR_VIEW) {
            mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset);
        }
    }

    mHapticFeedbackController = new HapticFeedbackController(activity);

    int mainColor1 = themeColors.getColor(R.styleable.BetterPickersDialog_bpMainColor1, R.color.bpWhite);
    int mainColor2 = themeColors.getColor(R.styleable.BetterPickersDialog_bpMainColor2,
            R.color.circle_background);
    int backgroundColor = themeColors.getColor(R.styleable.BetterPickersDialog_bpLineColor, R.color.bpWhite);

    mDayPickerView.setTheme(themeColors);
    mYearPickerView.setTheme(themeColors);

    mSelectedDateLayout.setBackgroundColor(mainColor1);
    mYearView.setBackgroundColor(mainColor1);
    mMonthAndDayView.setBackgroundColor(mainColor1);

    view.setBackgroundColor(mainColor2);
    if (mDayOfWeekView != null) {
        mDayOfWeekView.setBackgroundColor(backgroundColor);
    }
    mYearPickerView.setBackgroundColor(mainColor2);
    mDayPickerView.setBackgroundColor(mainColor2);

    return view;
}

From source file:com.example.testtab.fragment.TwitEyesPageFragment.java

public void showProgressBar(int percent) {
    TextView textLayer = (TextView) this.mRootView.findViewById(R.id.progress_bar);
    AnimationSet set = new AnimationSet(true);

    // ALPHA/*from   ww  w  .java2 s.  c  o  m*/
    AlphaAnimation alpha;
    switch (percent) {
    case 100:
        alpha = new AlphaAnimation(1.0f, 0.0f);
        break;
    case 0:
        alpha = new AlphaAnimation(0.0f, 1.0f);
        break;
    default:
        alpha = new AlphaAnimation(0.8f, 1.0f);
    }
    alpha.setDuration(500);

    TranslateAnimation translate;
    float toX = ((float) percent - 100.0f) / 100.0f;
    float fromX = toX - 0.1f;
    translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, fromX, Animation.RELATIVE_TO_PARENT, toX,
            Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f);
    translate.setDuration(500);
    translate.setInterpolator(new BounceInterpolator());

    set.addAnimation(alpha);
    set.addAnimation(translate);
    //         set.setDuration(500);
    set.setFillBefore(true);
    set.setFillAfter(true);

    textLayer.startAnimation(set);
}

From source file:it.imwatch.nfclottery.dialogs.InsertContactDialog.java

/**
 * Hides the email error textview.//  w w w  . j a  v a2  s .  c om
 */
private void hideEmailError() {
    mEmailErrorState = 0;

    // Re-enable the positive button of the dialog iif the name is also valid
    setFormIsValidated(mNameErrorState == 0);

    if (mEmailErrorTextView.getVisibility() == View.GONE) {
        return; // No need to animate out the textview, it's already gone
    }

    AnimationSet fadeOutSet = new AnimationSet(true);
    fadeOutSet.addAnimation(new AlphaAnimation(1f, 0f));
    fadeOutSet.addAnimation(new TranslateAnimation(0f, 0f, 0f, -mErrorAnimTranslateY));
    fadeOutSet.setDuration(300);
    fadeOutSet.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            // Don't care
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mEmailErrorTextView.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
            // Don't care
        }
    });

    mEmailErrorTextView.startAnimation(fadeOutSet);
}

From source file:de.fahrgemeinschaft.RideDetailsFragment.java

private void fadeOutFast(final View view) {
    Animation fade_out = new AlphaAnimation(0.5f, 0f);
    fade_out.setAnimationListener(new AnimationListener() {

        @Override//  ww  w  .j  a  v a2s. c  om
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
        }
    });
    fade_out.setDuration(300);
    fade_out.setFillAfter(true);
    view.startAnimation(fade_out);
}