List of usage examples for android.view.animation AccelerateInterpolator AccelerateInterpolator
public AccelerateInterpolator()
From source file:acr.browser.lightning.browser.fragment.anim.VerticalItemAnimator.java
private void animateRemoveImpl(final ViewHolder holder) { final View view = holder.itemView; final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view); mRemoveAnimations.add(holder);//from w ww. j a v a 2s.c o m animation.setDuration(getRemoveDuration()).alpha(0).translationX(-holder.itemView.getWidth() / 2) .setInterpolator(new AccelerateInterpolator()).setListener(new VpaListenerAdapter() { @Override public void onAnimationStart(View view) { dispatchRemoveStarting(holder); } @Override public void onAnimationEnd(View view) { animation.setListener(null); ViewCompat.setAlpha(view, 1); ViewCompat.setTranslationX(view, 0); dispatchRemoveFinished(holder); mRemoveAnimations.remove(holder); dispatchFinishedWhenDone(); } }).start(); }
From source file:android.support.design.widget.TextInputLayout.java
public TextInputLayout(Context context, AttributeSet attrs, int defStyleAttr) { // Can't call through to super(Context, AttributeSet, int) since it doesn't exist on API 10 super(context, attrs); ThemeUtils.checkAppCompatTheme(context); setOrientation(VERTICAL);/* w w w . j a v a2s.c om*/ setWillNotDraw(false); setAddStatesFromChildren(true); mInputFrame = new FrameLayout(context); mInputFrame.setAddStatesFromChildren(true); addView(mInputFrame); mCollapsingTextHelper.setTextSizeInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR); mCollapsingTextHelper.setPositionInterpolator(new AccelerateInterpolator()); mCollapsingTextHelper.setCollapsedTextGravity(Gravity.TOP | GravityCompat.START); final TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.TextInputLayout, defStyleAttr, R.style.Widget_Design_TextInputLayout); mHintEnabled = a.getBoolean(R.styleable.TextInputLayout_hintEnabled, true); setHint(a.getText(R.styleable.TextInputLayout_android_hint)); mHintAnimationEnabled = a.getBoolean(R.styleable.TextInputLayout_hintAnimationEnabled, true); if (a.hasValue(R.styleable.TextInputLayout_android_textColorHint)) { mDefaultTextColor = mFocusedTextColor = a .getColorStateList(R.styleable.TextInputLayout_android_textColorHint); } final int hintAppearance = a.getResourceId(R.styleable.TextInputLayout_hintTextAppearance, -1); if (hintAppearance != -1) { setHintTextAppearance(a.getResourceId(R.styleable.TextInputLayout_hintTextAppearance, 0)); } mErrorTextAppearance = a.getResourceId(R.styleable.TextInputLayout_errorTextAppearance, 0); final boolean errorEnabled = a.getBoolean(R.styleable.TextInputLayout_errorEnabled, false); final boolean counterEnabled = a.getBoolean(R.styleable.TextInputLayout_counterEnabled, false); setCounterMaxLength(a.getInt(R.styleable.TextInputLayout_counterMaxLength, INVALID_MAX_LENGTH)); mCounterTextAppearance = a.getResourceId(R.styleable.TextInputLayout_counterTextAppearance, 0); mCounterOverflowTextAppearance = a.getResourceId(R.styleable.TextInputLayout_counterOverflowTextAppearance, 0); mPasswordToggleEnabled = a.getBoolean(R.styleable.TextInputLayout_passwordToggleEnabled, false); mPasswordToggleDrawable = a.getDrawable(R.styleable.TextInputLayout_passwordToggleDrawable); mPasswordToggleContentDesc = a.getText(R.styleable.TextInputLayout_passwordToggleContentDescription); if (a.hasValue(R.styleable.TextInputLayout_passwordToggleTint)) { mHasPasswordToggleTintList = true; mPasswordToggleTintList = a.getColorStateList(R.styleable.TextInputLayout_passwordToggleTint); } if (a.hasValue(R.styleable.TextInputLayout_passwordToggleTintMode)) { mHasPasswordToggleTintMode = true; mPasswordToggleTintMode = ViewUtils .parseTintMode(a.getInt(R.styleable.TextInputLayout_passwordToggleTintMode, -1), null); } a.recycle(); setErrorEnabled(errorEnabled); setCounterEnabled(counterEnabled); applyPasswordToggleTint(); if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) { // Make sure we're important for accessibility if we haven't been explicitly not ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); } ViewCompat.setAccessibilityDelegate(this, new TextInputAccessibilityDelegate()); }
From source file:com.sociablue.nanodegree_p1.MovieListFragment.java
private void initializeFab(View rootView) { final RelativeLayout buttonContainer = (RelativeLayout) rootView.findViewById(R.id.menu_button_container); final FloatingActionButton Fab = (FloatingActionButton) rootView.findViewById(R.id.fab); final ImageView bottomBar = (ImageView) rootView.findViewById(R.id.menu_bottom_bar); final ImageView topBar = (ImageView) rootView.findViewById(R.id.menu_top_bar); Fab.setOnClickListener(new View.OnClickListener() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override//from w ww.j av a 2 s . c om public void onClick(View v) { //Menu Button Icon Animation //Setting up necessary variables long animationDuration = 500; float containerHeight = buttonContainer.getHeight(); float containerCenterY = containerHeight / 2; float containerCenterX = buttonContainer.getWidth() / 2; float topBarCenter = topBar.getTop() + topBar.getHeight() / 2; float widthOfBar = topBar.getWidth(); float heightOfBar = topBar.getHeight(); final float distanceBetweenBars = (containerCenterY - topBarCenter); /** *TODO: Refactor block of code to use Value Property Animator. Should be more efficient to animate multiple properties *and objects at the same time. Also, will try to break intialization into smaller functions. */ //Setting up animations of hamburger bars and rotation /** * Animation For Top Menu Button Icon Bar. Sliding from the top to rest on top of the middle bar. * Y Translation is 1/2 the height of the hamburger bar minus the distance. * Subtracting the distance from the height because the distance between bars is * calculated of the exact center of the button. * With out the subtraction the bar would translate slightly below the middle bar. */ float yTranslation = heightOfBar / 2 - distanceBetweenBars; float xTranslation = widthOfBar / 2 + heightOfBar / 2; TranslateAnimation topBarTranslationAnim = new TranslateAnimation(Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, 0F, Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, distanceBetweenBars); topBarTranslationAnim.setDuration((long) (animationDuration * 0.8)); topBarTranslationAnim.setFillAfter(true); //Animation for bottom hamburger bar. Translates and Rotates to create 'X' AnimationSet bottomBarAnimation = new AnimationSet(true); bottomBarAnimation.setFillAfter(true); //Rotate to create cross. (The cross becomes the X after the button rotation completes" RotateAnimation bottomBarRotationAnimation = new RotateAnimation(0f, 90f, Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 1f); bottomBarRotationAnimation.setDuration(animationDuration); bottomBarAnimation.addAnimation(bottomBarRotationAnimation); //Translate to correct X alignment TranslateAnimation bottomBarTranslationAnimation = new TranslateAnimation(Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, -xTranslation, Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, -yTranslation); bottomBarTranslationAnimation.setDuration(animationDuration); bottomBarAnimation.addAnimation(bottomBarTranslationAnimation); //Button Specific Animations //Rotate Button Container RotateAnimation containerRotationAnimation = new RotateAnimation(0, 135f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); containerRotationAnimation.setDuration(animationDuration); containerRotationAnimation.setFillAfter(true); //Animate change of button color between Active and Disabled colors that have been //defined in color.xml int activeColor = getResources().getColor(R.color.active_button); int disabledColor = getResources().getColor(R.color.disabled_button); //Need to use ValueAnimator because property animator does not support BackgroundTint ValueAnimator buttonColorAnimation = ValueAnimator.ofArgb(activeColor, disabledColor); buttonColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { Fab.setBackgroundTintList(ColorStateList.valueOf((int) animation.getAnimatedValue())); } }); buttonColorAnimation.setDuration(animationDuration); //Start all the animations topBar.startAnimation(topBarTranslationAnim); bottomBar.startAnimation(bottomBarAnimation); buttonContainer.startAnimation(containerRotationAnimation); buttonColorAnimation.start(); //Toogle mMenu open and closed if (mMenu.isOpen()) { //If mMenu is open, do the reverse of the animation containerRotationAnimation .setInterpolator(new ReverseInterpolator(new AccelerateInterpolator())); topBarTranslationAnim.setInterpolator(new ReverseInterpolator(new AccelerateInterpolator())); bottomBarAnimation.setInterpolator(new ReverseInterpolator(new AccelerateInterpolator())); buttonColorAnimation.setInterpolator(new ReverseInterpolator(new LinearInterpolator())); mMenu.close(); } else { bottomBarAnimation.setInterpolator(new AccelerateInterpolator()); mMenu.open(); } } }); }
From source file:com.glabs.homegenie.StartActivity.java
public void hideLogo() { _islogovisible = false;/*from w w w . j a va 2 s .com*/ runOnUiThread(new Runnable() { @Override public void run() { Animation fadeOut = new AlphaAnimation(0.8f, 0); fadeOut.setInterpolator(new AccelerateInterpolator()); //and this fadeOut.setStartOffset(0); fadeOut.setDuration(500); // AnimationSet animation = new AnimationSet(false); //change to false animation.addAnimation(fadeOut); animation.setFillAfter(true); RelativeLayout ivlogo = (RelativeLayout) findViewById(R.id.logo); ivlogo.startAnimation(animation); } }); }
From source file:com.commonsware.cwac.crossport.design.widget.TextInputLayout.java
public TextInputLayout(Context context, AttributeSet attrs, int defStyleAttr) { // Can't call through to super(Context, AttributeSet, int) since it doesn't exist on API 10 super(context, attrs); // ThemeUtils.checkAppCompatTheme(context); setOrientation(VERTICAL);//from w w w. j a v a 2 s . c om setWillNotDraw(false); setAddStatesFromChildren(true); mInputFrame = new FrameLayout(context); mInputFrame.setAddStatesFromChildren(true); addView(mInputFrame); mCollapsingTextHelper.setTextSizeInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR); mCollapsingTextHelper.setPositionInterpolator(new AccelerateInterpolator()); mCollapsingTextHelper.setCollapsedTextGravity(Gravity.TOP | GravityCompat.START); mHintExpanded = mCollapsingTextHelper.getExpansionFraction() == 1f; final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TextInputLayout, defStyleAttr, R.style.Widget_Design_TextInputLayout); mHintEnabled = a.getBoolean(R.styleable.TextInputLayout_hintEnabled, true); setHint(a.getText(R.styleable.TextInputLayout_android_hint)); mHintAnimationEnabled = a.getBoolean(R.styleable.TextInputLayout_hintAnimationEnabled, true); if (a.hasValue(R.styleable.TextInputLayout_android_textColorHint)) { mDefaultTextColor = mFocusedTextColor = a .getColorStateList(R.styleable.TextInputLayout_android_textColorHint); } final int hintAppearance = a.getResourceId(R.styleable.TextInputLayout_hintTextAppearance, -1); if (hintAppearance != -1) { setHintTextAppearance(a.getResourceId(R.styleable.TextInputLayout_hintTextAppearance, 0)); } mErrorTextAppearance = a.getResourceId(R.styleable.TextInputLayout_errorTextAppearance, 0); final boolean errorEnabled = a.getBoolean(R.styleable.TextInputLayout_errorEnabled, false); final boolean counterEnabled = a.getBoolean(R.styleable.TextInputLayout_counterEnabled, false); setCounterMaxLength(a.getInt(R.styleable.TextInputLayout_counterMaxLength, INVALID_MAX_LENGTH)); mCounterTextAppearance = a.getResourceId(R.styleable.TextInputLayout_counterTextAppearance, 0); mCounterOverflowTextAppearance = a.getResourceId(R.styleable.TextInputLayout_counterOverflowTextAppearance, 0); mPasswordToggleEnabled = a.getBoolean(R.styleable.TextInputLayout_passwordToggleEnabled, false); mPasswordToggleDrawable = a.getDrawable(R.styleable.TextInputLayout_passwordToggleDrawable); mPasswordToggleContentDesc = a.getText(R.styleable.TextInputLayout_passwordToggleContentDescription); if (a.hasValue(R.styleable.TextInputLayout_passwordToggleTint)) { mHasPasswordToggleTintList = true; mPasswordToggleTintList = a.getColorStateList(R.styleable.TextInputLayout_passwordToggleTint); } if (a.hasValue(R.styleable.TextInputLayout_passwordToggleTintMode)) { mHasPasswordToggleTintMode = true; mPasswordToggleTintMode = ViewUtils .parseTintMode(a.getInt(R.styleable.TextInputLayout_passwordToggleTintMode, -1), null); } a.recycle(); setErrorEnabled(errorEnabled); setCounterEnabled(counterEnabled); applyPasswordToggleTint(); if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) { // Make sure we're important for accessibility if we haven't been explicitly not ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); } ViewCompat.setAccessibilityDelegate(this, new TextInputAccessibilityDelegate()); }
From source file:org.codeforafrica.citizenreporter.eNCA.widgets.SlidingTabLayout.java
public void setBadge(int position, boolean isBadged) { final View badgeView = mTabStrip.findViewWithTag(makeBadgeTag(position)); if (badgeView == null) { return;//from w w w . j a v a 2s .c o m } boolean wasBadged = (badgeView.getVisibility() == View.VISIBLE); if (isBadged == wasBadged) { return; } float start = isBadged ? 0f : 1f; float end = isBadged ? 1f : 0f; PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, start, end); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, start, end); ObjectAnimator animScale = ObjectAnimator.ofPropertyValuesHolder(badgeView, scaleX, scaleY); if (isBadged) { animScale.setInterpolator(new BounceInterpolator()); animScale.setDuration(getContext().getResources().getInteger(android.R.integer.config_longAnimTime)); animScale.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { badgeView.setVisibility(View.VISIBLE); } }); } else { animScale.setInterpolator(new AccelerateInterpolator()); animScale.setDuration(getContext().getResources().getInteger(android.R.integer.config_shortAnimTime)); animScale.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { badgeView.setVisibility(View.GONE); } }); } animScale.start(); }
From source file:de.schildbach.wallet.ui.scan.ScanActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); viewModel = ViewModelProviders.of(this).get(ScanViewModel.class); viewModel.showPermissionWarnDialog.observe(this, new Observer<Void>() { @Override/*from ww w.j av a2 s . c o m*/ public void onChanged(final Void v) { WarnDialogFragment.show(getSupportFragmentManager(), R.string.scan_camera_permission_dialog_title, getString(R.string.scan_camera_permission_dialog_message)); } }); viewModel.showProblemWarnDialog.observe(this, new Observer<Void>() { @Override public void onChanged(final Void v) { WarnDialogFragment.show(getSupportFragmentManager(), R.string.scan_camera_problem_dialog_title, getString(R.string.scan_camera_problem_dialog_message)); } }); // Stick to the orientation the activity was started with. We cannot declare this in the // AndroidManifest.xml, because it's not allowed in combination with the windowIsTranslucent=true // theme attribute. setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED); // Draw under navigation and status bars. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); setContentView(R.layout.scan_activity); contentView = findViewById(android.R.id.content); scannerView = (ScannerView) findViewById(R.id.scan_activity_mask); previewView = (TextureView) findViewById(R.id.scan_activity_preview); previewView.setSurfaceTextureListener(this); cameraThread = new HandlerThread("cameraThread", Process.THREAD_PRIORITY_BACKGROUND); cameraThread.start(); cameraHandler = new Handler(cameraThread.getLooper()); if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.CAMERA }, 0); if (savedInstanceState == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { final Intent intent = getIntent(); final int x = intent.getIntExtra(INTENT_EXTRA_SCENE_TRANSITION_X, -1); final int y = intent.getIntExtra(INTENT_EXTRA_SCENE_TRANSITION_Y, -1); if (x != -1 || y != -1) { // Using alpha rather than visibility because 'invisible' will cause the surface view to never // start up, so the animation will never start. contentView.setAlpha(0); getWindow().setBackgroundDrawable( new ColorDrawable(getResources().getColor(android.R.color.transparent))); OnFirstPreDraw.listen(contentView, new OnFirstPreDraw.Callback() { @Override public boolean onFirstPreDraw() { float finalRadius = (float) (Math.max(contentView.getWidth(), contentView.getHeight())); final int duration = getResources().getInteger(android.R.integer.config_mediumAnimTime); sceneTransition = ViewAnimationUtils.createCircularReveal(contentView, x, y, 0, finalRadius); sceneTransition.setDuration(duration); sceneTransition.setInterpolator(new AccelerateInterpolator()); // TODO Here, the transition should start in a paused state, showing the first frame // of the animation. Sadly, RevealAnimator doesn't seem to support this, unlike // (subclasses of) ValueAnimator. return false; } }); } } }
From source file:com.miz.utils.ViewUtils.java
/** * Animates the transition when changing the maxLines * attribute of a TextView.//w w w.j a v a 2 s. c om * @param text * @param maxLines */ public static void animateTextViewMaxLines(TextView text, int maxLines) { try { ObjectAnimator animation = ObjectAnimator.ofInt(text, "maxLines", maxLines); animation.setInterpolator(new AccelerateInterpolator()); animation.setDuration(200); animation.start(); } catch (Exception e) { // Some devices crash at runtime when using the ObjectAnimator text.setMaxLines(maxLines); } }
From source file:com.example.fragment.PrimitiveFragment.java
public void testAnimation(float destX, float destY) { this.mDestX = Factory.getAdjustedX(destX); this.mDestY = Factory.getAdjustedY(destY); // SELECT LAYER FrameLayout relate = (FrameLayout) mRootView.findViewById(R.id.FLBackLayer); // ScrollView relate = (ScrollView)mRootView.findViewById(R.id.content); // relate.setVisibility(View.VISIBLE); AnimationSet set = new AnimationSet(true); set.setAnimationListener(this); TranslateAnimation translate;/*from w w w . ja v a2 s . c o m*/ float toX = this.mDestX; float fromX = this.mSrcX; float toY = this.mDestY; float fromY = this.mSrcY; translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, fromX, Animation.RELATIVE_TO_PARENT, toX, Animation.RELATIVE_TO_PARENT, fromY, Animation.RELATIVE_TO_PARENT, toY); translate.setDuration(Constants.Animation.IPF_START); translate.setInterpolator(new AccelerateInterpolator()); set.addAnimation(translate); set.setFillBefore(true); // set.setFillBefore(false); // set.setFillAfter(false); set.setFillAfter(true); relate.startAnimation(set); }
From source file:com.calgen.udacity.lego.ui.ArticleDetailFragment.java
private void playAnimation(ImageView photoView) { Animation fadeIn = new AlphaAnimation(0, 1); fadeIn.setInterpolator(new AccelerateInterpolator()); fadeIn.setDuration(500);/*from w ww . ja v a 2 s .c om*/ photoView.startAnimation(fadeIn); shareFab.setVisibility(View.VISIBLE); shareFab.startAnimation(fadeIn); }