마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

Number Count Animation 질문합니다.

0 추천

 

 

https://lottiefiles.com/64832-lottie1#

위 링크의 gif 파일 처럼 textview가 한 글자씩 도미노처럼 끊어지는 느낌이 아니라 부드럽게 이어져서 나오게 하고 싶은데 방법이 있을까요??

현재 제 코드 입니다

MainActivity.kt

class MainActivity : AppCompatActivity() {
    var text = "946327"
    var hand: Handler? = null
    var runnner: Runnable? = null
    var lenght = text.length
    var index = 0
    public override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        button.setOnClickListener {
            textView.text = (text.toInt()+1).toString()
        }

        hand = Handler()
        val rand = Random()
        runnner = Runnable {
            if (index < lenght) {
                val flowString: String = text.substring(0, ++index)
                Log.d("DEBUG:", flowString)
                textView.text = flowString
                textView.offsetLeftAndRight(3)
                hand!!.postDelayed(runnner!!, 500)
            }
        }
        hand!!.post(runnner!!)
    }
}

 

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <LinearLayout
        android:id="@+id/line1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="vertical"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:paddingBottom="@dimen/activity_horizontal_margin"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <com.robinhood.ticker.TickerView
            android:id="@+id/textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:padding="4dp"
            android:text=" "
            android:textColor="#000000"
            android:textSize="64sp"
            app:ticker_defaultCharacterList="number"/>

    </LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
poppy (120 포인트) 님이 2021년 10월 28일 질문

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...