Example usage for android.view.animation ScaleAnimation ScaleAnimation

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

Introduction

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

Prototype

public ScaleAnimation(float fromX, float toX, float fromY, float toY) 

Source Link

Document

Constructor to use when building a ScaleAnimation from code

Usage

From source file:it.bellotti.android.materialdesignsample.ui.widget.ScrollAwareFABBehavior.java

private void animateFabIn(final FloatingActionButton button) {
    button.setVisibility(View.VISIBLE);
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).scaleX(1.0F).scaleY(1.0F).alpha(1.0F).setInterpolator(INTERPOLATOR)
                .withLayer().setListener(null).start();
    } else {/* w  ww.  j  av a2  s . c o m*/
        Animation anim = new ScaleAnimation(0.0F, 0.0F, 1.0F, 1.0F);
        anim.setDuration(200L);
        anim.setInterpolator(INTERPOLATOR);
        anim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                button.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
        button.startAnimation(anim);
    }
}

From source file:quickbeer.android.next.views.ProgressIndicatorBar.java

private void animateToProgress(float progress) {
    Log.v(TAG, "animateToProgress(" + progress + ")");

    float newScale = (getWidth() * progress / progressBarWidth) + 1;

    ScaleAnimation animation = new ScaleAnimation(1, newScale, progressBar.getHeight(),
            progressBar.getHeight());//from  w  w w.  j a  v a 2 s  .c  o m
    animation.setDuration(ANIMATION_PROGRESS_DURATION);
    animation.setFillAfter(true);

    progressBar.setVisibility(VISIBLE);
    progressBar.clearAnimation();
    progressBar.startAnimation(animation);
}

From source file:quickbeer.android.next.views.ProgressIndicatorBar.java

private void animateToEnd() {
    Log.v(TAG, "animateToEnd()");

    if (progressBar.getAnimation() == null) {
        // Non-active progress bar doesn't need end animation
        return;//from   w  w w  .ja  va  2  s .  c o m
    }

    ScaleAnimation animation = new ScaleAnimation(1, (getWidth() / progressBarWidth) + 1,
            progressBar.getHeight(), progressBar.getHeight());
    animation.setDuration(ANIMATION_END_SCALE_DURATION);
    animation.setFillAfter(true);
    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            animateToHidden();
        }
    });

    progressBar.setVisibility(VISIBLE);
    progressBar.clearAnimation();
    progressBar.startAnimation(animation);
}

From source file:quickbeer.android.views.ProgressIndicatorBar.java

private void animateToProgress(float progress) {
    Timber.v("animateToProgress(%s)", progress);
    checkNotNull(progressBar);//from   w w  w  .j  av  a2s .  c om

    float newScale = (getWidth() * progress / progressBarWidth) + 1;

    Timber.v("animate scale %s -> %s", barScale, newScale);

    ScaleAnimation animation = new ScaleAnimation(barScale, newScale, progressBar.getHeight(),
            progressBar.getHeight());
    animation.setDuration(ANIMATION_PROGRESS_DURATION);
    animation.setFillAfter(true);
    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            barScale = newScale;
            applyNextStatus();
        }
    });

    progressBar.setVisibility(VISIBLE);
    progressBar.clearAnimation();
    progressBar.startAnimation(animation);
}

From source file:quickbeer.android.views.ProgressIndicatorBar.java

private void animateToEnd() {
    Timber.v("animateToEnd()");
    checkNotNull(progressBar);/*from   w  w  w .  j  ava 2  s. c o m*/

    if (progressBar.getAnimation() == null) {
        // Non-active progress bar doesn't need end animation
        return;
    }

    ScaleAnimation animation = new ScaleAnimation(barScale, (getWidth() / (float) progressBarWidth) + 1,
            progressBar.getHeight(), progressBar.getHeight());
    animation.setDuration(ANIMATION_END_SCALE_DURATION);
    animation.setFillAfter(true);
    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            barScale = 1.0f;
            animateToHidden();
        }
    });

    progressBar.setVisibility(VISIBLE);
    progressBar.clearAnimation();
    progressBar.startAnimation(animation);
}

From source file:com.osama.cgpacalculator.MainActivity.java

private void animateWhat() {
    Animation animation = new ScaleAnimation(0f, 1f, 0f, 1f);
    animation.setDuration(800);// ww  w. j av a2  s.c  o m
    mSubjectsList.setAnimation(animation);
    mSubjectsList.animate();
}

From source file:com.osama.cgpacalculator.MainActivity.java

private void gpaAnimation(View view) {
    ScaleAnimation animation = new ScaleAnimation(0f, 1f, 1f, 1f);
    animation.setDuration(500);//ww w  . jav  a2  s . c  o m
    view.setAnimation(animation);
    view.animate();
}

From source file:uk.org.ngo.squeezer.itemlist.AlarmView.java

private View getAdapterView(View convertView, final ViewGroup parent) {
    AlarmViewHolder currentViewHolder = (convertView != null && convertView.getTag() instanceof AlarmViewHolder)
            ? (AlarmViewHolder) convertView.getTag()
            : null;/*from  w w w . ja  v  a2s. c om*/

    if (currentViewHolder == null) {
        convertView = getLayoutInflater().inflate(R.layout.list_item_alarm, parent, false);
        final View alarmView = convertView;
        final AlarmViewHolder viewHolder = new AlarmViewHolder();
        viewHolder.is24HourFormat = DateFormat.is24HourFormat(getActivity());
        viewHolder.timeFormat = viewHolder.is24HourFormat ? "%02d:%02d" : "%d:%02d";
        String[] amPmStrings = new DateFormatSymbols().getAmPmStrings();
        viewHolder.am = amPmStrings[0];
        viewHolder.pm = amPmStrings[1];
        viewHolder.time = (TextView) convertView.findViewById(R.id.time);
        viewHolder.amPm = (TextView) convertView.findViewById(R.id.am_pm);
        viewHolder.amPm.setVisibility(viewHolder.is24HourFormat ? View.GONE : View.VISIBLE);
        viewHolder.enabled = new CompoundButtonWrapper((CompoundButton) convertView.findViewById(R.id.enabled));
        viewHolder.enabled.setOncheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                if (getActivity().getService() != null) {
                    viewHolder.alarm.setEnabled(b);
                    getActivity().getService().alarmEnable(viewHolder.alarm.getId(), b);
                }
            }
        });
        viewHolder.repeat = new CompoundButtonWrapper((CompoundButton) convertView.findViewById(R.id.repeat));
        viewHolder.repeat.setOncheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                if (getActivity().getService() != null) {
                    viewHolder.alarm.setRepeat(b);
                    getActivity().getService().alarmRepeat(viewHolder.alarm.getId(), b);
                    viewHolder.dowHolder.setVisibility(b ? View.VISIBLE : View.GONE);
                }
            }
        });
        viewHolder.repeat.getButton().setText(ServerString.ALARM_ALARM_REPEAT.getLocalizedString());
        viewHolder.delete = (ImageView) convertView.findViewById(R.id.delete);
        viewHolder.playlist = (Spinner) convertView.findViewById(R.id.playlist);
        viewHolder.dowHolder = (LinearLayout) convertView.findViewById(R.id.dow);
        for (int day = 0; day < 7; day++) {
            ViewGroup dowButton = (ViewGroup) viewHolder.dowHolder.getChildAt(day);
            final int finalDay = day;
            dowButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (getActivity().getService() != null) {
                        final Alarm alarm = viewHolder.alarm;
                        boolean wasChecked = alarm.isDayActive(finalDay);
                        if (wasChecked) {
                            alarm.clearDay(finalDay);
                            getActivity().getService().alarmRemoveDay(alarm.getId(), finalDay);
                        } else {
                            alarm.setDay(finalDay);
                            getActivity().getService().alarmAddDay(alarm.getId(), finalDay);
                        }
                        setDowText(viewHolder, finalDay);
                    }
                }
            });
            viewHolder.dowTexts[day] = (TextView) dowButton.getChildAt(0);
        }
        viewHolder.delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View view) {
                final AnimationSet animationSet = new AnimationSet(true);
                animationSet.addAnimation(new ScaleAnimation(1F, 1F, 1F, 0.5F));
                animationSet.addAnimation(new AlphaAnimation(1F, 0F));
                animationSet.setDuration(ANIMATION_DURATION);
                animationSet.setAnimationListener(new AnimationEndListener() {
                    @Override
                    public void onAnimationEnd(Animation animation) {
                        mActivity.getItemAdapter().removeItem(viewHolder.position);
                        UndoBarController.show(getActivity(), ServerString.ALARM_DELETING.getLocalizedString(),
                                new UndoListener(viewHolder.position, viewHolder.alarm));
                    }
                });

                alarmView.startAnimation(animationSet);
            }
        });
        viewHolder.playlist.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                final AlarmPlaylist selectedAlarmPlaylist = mAlarmPlaylists.get(position);
                final Alarm alarm = viewHolder.alarm;
                if (getActivity().getService() != null && selectedAlarmPlaylist.getId() != null
                        && !selectedAlarmPlaylist.getId().equals(alarm.getUrl())) {
                    alarm.setUrl(selectedAlarmPlaylist.getId());
                    getActivity().getService().alarmSetPlaylist(alarm.getId(), selectedAlarmPlaylist);
                }
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {
            }
        });

        convertView.setTag(viewHolder);
    }

    return convertView;
}

From source file:enterprayz.megatools.Tools.java

public static void replace(View source, int xTo, int yTo, float xScale, float yScale) {
    AnimationSet replaceAnimation = new AnimationSet(false);
    replaceAnimation.setFillAfter(true);

    ScaleAnimation scale = new ScaleAnimation(1.0f, xScale, 1.0f, yScale);
    scale.setDuration(1000);//from   www.  j  a  va  2 s.c o m

    TranslateAnimation trans = new TranslateAnimation(0, 0, TranslateAnimation.ABSOLUTE, xTo - source.getLeft(),
            0, 0, TranslateAnimation.ABSOLUTE, yTo - source.getTop());
    trans.setDuration(1000);

    replaceAnimation.addAnimation(scale);
    replaceAnimation.addAnimation(trans);

    source.startAnimation(replaceAnimation);
}

From source file:com.umeng.comm.ui.adapters.viewholders.FeedItemViewHolder.java

private void clickAnima(View targetView) {
    ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 1.1f, 1.0f, 1.1f);
    scaleAnimation.setDuration(100);/* w  ww  .j a  v  a 2  s. c om*/
    targetView.startAnimation(scaleAnimation);
}