Nombre de animación desconocido: decelerateInterpolator

Android Studio 1.5 Device Samsung 4.4.2 

Estoy intentando animar los artículos cargados de un ArrayList en un recyclerview. Cuando se hace clic en la flecha desplegable, los elementos deben animarse (desacelerar) cuando se expanden y deben animarse cuando se colapsan. Sin embargo, actualmente los elementos de la lista sólo aparecen.

Código que llama a setAnimation

  @Override public void onBindChildViewHolder(ChatChildViewHolder childViewHolder, int position, Object childListItem) { ChatChildTitles chatChildTitles = (ChatChildTitles)childListItem; childViewHolder.tvChildTitle.setText(chatChildTitles.getTitle()); setAnimation(childViewHolder.cvChildRooms, position); } 

Código para configurar la animación

  private void setAnimation(CardView viewToAnimate, int position) { Animation animation = AnimationUtils.loadAnimation(mContext, android.R.anim.fade_in); animation.setInterpolator(mContext, android.R.anim.decelerate_interpolator); viewToAnimate.startAnimation(animation); } 

Aquí hay un par de capturas de pantalla:

En el estado colapsado

Introduzca aquí la descripción de la imagen

Después de hacer clic en la flecha expland la lista Introduzca aquí la descripción de la imagen

Este es mi diseño que estoy usando que representa las filas que se mostrarán en el recicladorVer:

 <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.CardView android:id="@+id/cvChildRooms" xmlns:card="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" card:cardBackgroundColor="@color/child_header_lighter_grey" card:contentPadding="4dp" card:cardPreventCornerOverlap="true"> <de.hdodenhof.circleimageview.CircleImageView android:id="@+id/profile_image" android:layout_width="40dp" android:layout_height="40dp" android:layout_gravity="center_vertical|start" android:src="@drawable/photorace"/> <TextView android:id="@+id/tvChildTitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical|center" android:text="Coffee Latte Room" android:fontFamily="sans-serif-light" android:textSize="16sp" android:textColor="@android:color/black"/> </android.support.v7.widget.CardView> 

Tengo una función que debe comenzar la animación.

 private void setAnimation(CardView viewToAnimate, int position) { Animation animation = AnimationUtils.loadAnimation(mContext, android.R.anim.decelerate_interpolator); viewToAnimate.startAnimation(animation); } 

He probado con lo siguiente que funciona bien con slide_in_left . Sin embargo, no quiero que se deslice desde la izquierda

 Animation animation = AnimationUtils.loadAnimation(mContext, android.R.anim.slide_in_left); viewToAnimate.startAnimation(animation); 

Muchas gracias por las sugerencias,

Si desea utilizar un interpolador de desaceleración , debe configurarlo como un interpolador, no como el animador :

 private void setAnimation(CardView viewToAnimate, int position) { Animation animation = AnimationUtils.loadAnimation(mContext, android.R.anim.fade_in); //change this with your desidered (or custom) animation animation.setInterpolator(mContext, android.R.anim.decelerate_interpolator); viewToAnimate.startAnimation(animation); } 

ACTUALIZAR

Usted dijo que está usando com.bignerdranch.android:expandablerecyclerview:2.0.3 .

De los documentos oficiales de la biblioteca, se indica claramente cómo crear animaciones de expansión / contracción :

También puede crear sus propias animaciones para la expansión reemplazando ParentViewHolder#onExpansionToggled(boolean) , que se llamará para usted cuando el itemView se expande o contrae.

Le sugiero que eche un vistazo al ejemplo oficial de la biblioteca.

No puedes usar decelerate_interpolator porque no es una animación, es un interpolador:

Un interpolador define la velocidad de cambio de una animación. Esto permite acelerar, desacelerar, repetir los efectos básicos de animación (alpha, scale, translate, rotate), etc.

Referencia:
http://developer.android.com/reference/android/view/animation/Interpolator.html

Como puede ver el XML que describen son completamente diferentes:

Fuente de decelerate_interpolator.xml :

 <decelerateInterpolator /> 

Fuente de slide_in_left.xml :

 <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:fromXDelta="-50%p" android:toXDelta="0" android:duration="@android:integer/config_mediumAnimTime"/> <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="@android:integer/config_mediumAnimTime" /> </set> 

Para animar la lista a medida que se expanden y se contraen, considere el uso de un ItemAnimator de android.

Tendrás que configurar un itemAnimator personalizado, algo similar al del siguiente enlace:

https://gist.github.com/ademar111190/dc988c8d899dae0193f7

Establezca el itemAnimator en el método runPendingAnimations a su interpolador de desaceleración.

 @Override public void runPendingAnimations() { if (!mViewHolders.isEmpty()) { int animationDuration = 300; AnimatorSet animator; View target; for (final RecyclerView.ViewHolder viewHolder : mViewHolders) { target = viewHolder.itemView; target.setPivotX(target.getMeasuredWidth() / 2); target.setPivotY(target.getMeasuredHeight() / 2); animator = new AnimatorSet(); animator.playTogether( ObjectAnimator.ofFloat(target, "translationX", -target.getMeasuredWidth(), 0.0f), ObjectAnimator.ofFloat(target, "alpha", target.getAlpha(), 1.0f) ); animator.setTarget(target); animator.setDuration(animationDuration); animator.setInterpolator(new DecelerateInterpolator()); animator.setStartDelay((animationDuration * viewHolder.getPosition()) / 10); animator.addListener(new AnimatorListener() { @Override public void onAnimationEnd(Animator animation) { mViewHolders.remove(viewHolder); } }); animator.start(); } } } 

Entonces necesitará establecer el itemAnimator en la vista del reciclador.

RecyclerView.setItemAnimator (nuevo MyItemAnimator ());

Puede utilizar el código a continuación para hacer eso.

 private void hideViews() { recyclerView.animate().translationY(-recyclerView.getHeight()).setInterpolator(new AccelerateInterpolator(2)); FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mFabButton.getLayoutParams(); int fabBottomMargin = lp.bottomMargin; mFabButton.animate().translationY(mFabButton.getHeight()+fabBottomMargin).setInterpolator(new AccelerateInterpolator(2)).start(); } private void showViews() { recyclerView.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)); mFabButton.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start(); } 

Puede llamar a este método onClick de su botón.

Espero que te ayude.

  • Simple animación de transporte en el diseño de Android no funciona por segunda vez
  • Android gridview expandir animación de elementos
  • Hacer animación de rebote
  • Android: ¿Cómo hacer la animación flip para la actividad de Android, al igual que el iphone flip horizontal de izquierda a derecha?
  • Android - ObjectAnimator establece el valor de pivot
  • ¿Cómo puedo reducir y deslizar una vista en el ángulo superior izquierdo?
  • ¿Puedo añadir AnimationListener para la traducción Fragment?
  • Biblioteca de soporte: Las animaciones de FragmentTransaction no funcionan
  • Estiramiento / escala de una región específica de vista / mapa de bits
  • Mostrar una letra de cadena por letra en un TextView -Android
  • Android Viewpager salta a la mitad de una página
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.