0

我正在创建一个动画,我必须将顶部 Compound Drawable 变形(转换)为 Left Compound Drawable。但我想以过渡或动画的方式来做,不是立即

在此处输入图像描述

单击上图时,它会向上移动一点并使用动画变形为下图。

在此处输入图像描述

我创建了一个带有顶部 Compound Drawable 的 textView 并希望将其缩小并设置左侧 Compound drawable 与动画(过渡)

源代码

mBinding.testTv.animate().translationYBy(-400.0f)
                //.scaleXBy(-0.25f).scaleYBy(-0.25f)
                . setDuration(1500).
                withEndAction {
                    val mDrawable = ContextCompat.getDrawable(this@TestActivity,R.drawable.ic_bored)
                    mBinding.testTv.setCompoundDrawablesRelativeWithIntrinsicBounds(mDrawable,null,null,null)
                 
                }.start()

毫升

<androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layoutDescription="@xml/fragment_bored_new_scene">

        <TextView
            android:id="@+id/test_tv"
            android:padding="24dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/bored_btn_bg"
            android:textSize="36sp"
            android:drawableTop="@drawable/ic_bored"
            android:text="FACTS"
            android:textColor="@color/colorPrimary" />


    </androidx.constraintlayout.widget.ConstraintLayout>
4

0 回答 0