¿Cómo se puede utilizar ViewPropertyAnimator para establecer Width a un valor específico
¿Cómo puedo usar ViewPropertyAnimator para establecer el ancho de mi vista?
Puedo escalar o traducir (ver abajo) pero no puedo fijar a una anchura específica.
- Superpuesto por la barra de estado cuando se muestra el fragmento de diálogo, solo en Android4.4
- Problemas con android-ffmpeg en Android Lollipop
- Ocultar el diálogo de impresión de Android KitKat 4.4
- API de notificación en el navegador Chrome de Android
- El constructor de vista personalizada en Android 4.4 se bloquea en Kotlin, ¿cómo arreglarlo?
frame_1.animate().scaleX(5).scaleY(5).start();
pero no hay
frame_1.animate().width(1024).height(768).start();
- Android: obtenga el resultado del cuadro de diálogo predeterminado de cambios de la aplicación de SMS
- Imprima varias páginas PDF utilizando el marco de impresión de Android 4.4
- ¿Cómo notificar correctamente a MediaScanner sobre una carpeta, incluso en dispositivos Nexus / Kitkat?
- Recibe mensajes MMS en Android KitKat
- En android 4.4, eliminar aplicaciones de tareas recientes mata permanentemente la aplicación con su servicio. ¿Alguna idea de por qué?
- Android 4.4 KitKat - ¿Cómo puedo evitar el nuevo selector de archivos?
- Volver automáticamente a la anterior aplicación de SMS predeterminada
- Error de licencia con el emulador de Android 4.4
Utilice animación simple en lugar de ViewPropertyAnimator
public class ResizeWidthAnimation extends Animation { private int mWidth; private int mStartWidth; private View mView; public ResizeWidthAnimation(View view, int width) { mView = view; mWidth = width; mStartWidth = view.getWidth(); } @Override protected void applyTransformation(float interpolatedTime, Transformation t) { int newWidth = mStartWidth + (int) ((mWidth - mStartWidth) * interpolatedTime); mView.getLayoutParams().width = newWidth; mView.requestLayout(); } @Override public void initialize(int width, int height, int parentWidth, int parentHeight) { super.initialize(width, height, parentWidth, parentHeight); } @Override public boolean willChangeBounds() { return true; }
}
Pruebe esto, soporte incluso desde Android 2.3:
ValueAnimatorCompat exitAnimator = AnimatorCompatHelper.emptyValueAnimator(); exitAnimator.setDuration(TransitCompat.ANIM_DURATION * 4); exitAnimator.addUpdateListener(new AnimatorUpdateListenerCompat() { private float oldWidth = view.getWidth(); private float endWidth = 0; private float oldHeight = view.getHeight(); private float endHeight = 0; private Interpolator interpolator2 = new BakedBezierInterpolator();//Any other will be also OK @Override public void onAnimationUpdate(ValueAnimatorCompat animation) { float fraction = interpolator2.getInterpolation(animation.getAnimatedFraction()); float width = oldWidth + (fraction * (endWidth - oldWidth)); mTarget.get().getLayoutParams().width = (int) width; float height = oldHeight + (fraction * (endHeight - oldHeight)); view.getLayoutParams().height = (int) height; view.requestLayout(); } }); exitAnimator.start();
- ¿Cómo descargar la imagen más rápido en android Volley / Picasso / Glide cualquier otro?
- Diferentes formas de publicar valores json en Server