0

I'm trying to combine scale and translate animation but my image after these animations is fragmented

Animations

//TODO: **Translate**

        val animatorLogoLoginTransaction = ObjectAnimator.ofFloat(
            logoLogin,
            View.TRANSLATION_Y,
            -logoStateTopValue
        )

        animatorLogoLoginTransaction.startDelay = 500
        animatorLogoLoginTransaction.duration = 1000
        animatorLogoLoginTransaction.start()

//TODO: **Scale**
 val scalaAnimation =  val scalaAnimation = ScaleAnimation(1f,0.4f,1f,0.4f,Animation.RELATIVE_TO_SELF,0f,Animation.RELATIVE_TO_SELF,0f)
        scalaAnimation.fillAfter = true
        scalaAnimation.duration = 1000
        logoLogin.startAnimation(scalaAnimation)

XML of my image view

<androidx.appcompat.widget.AppCompatImageView
            android:id="@+id/logoLogin"
            android:layout_width="wrap_content"
            android:layout_height="300dp"
            android:scaleType="fitStart"
            android:layout_marginStart="16dp"
            android:src="@drawable/vree_logo_large"
            app:layout_constraintTop_toTopOf="@id/limitGuideLogo"
            app:layout_constraintLeft_toLeftOf="parent"/>
Taslim Oseni
  • 6,086
  • 10
  • 44
  • 69

2 Answers2

0

You can do it simply in the java class where the view comes (activity/fragment/adapter..etc) like

 view.animate().rotationBy(360).translationX(50).scaleXBy(1).setDuration(1000);

Edit values as required

Athira
  • 1,177
  • 3
  • 13
  • 35
0

You should consider using the animation set. here is an example

Solution:

Translate

        val animatorLogoLoginTransaction = ObjectAnimator.ofFloat(
            logoLogin,
            View.TRANSLATION_Y,
            -logoStateTopValue
        )

        animatorLogoLoginTransaction.startDelay = 500

Scale

    val scalaAnimation = ScaleAnimation(1f,0.4f,1f,0.4f,
          Animation.RELATIVE_TO_SELF,0f,Animation.RELATIVE_TO_SELF,0f)

Combine

    val animSet = AnimationSet(true)
        animSet.fillAfter = true
        animSet.duration = 1000
        animSet.interpolator = BounceInterpolator()

        animSet.addAnimation(animatorLogoLoginTransaction)

        animSet.addAnimation(scalaAnimation)
        your_view.startAnimation(animSet)
Jasurbek
  • 2,946
  • 3
  • 20
  • 37