[Android] Realize text marquee effect (with as configuration)

1. Marquee effect

  1. The middle three lines of code set the single-line marquee to run all the time
    <TextView
        android:id="@+id/Run_textid"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:textSize="40dp"
        android:text="Hello World!Hello World!"
        
        android:ellipsize="marquee"
        android:marqueeRepeatLimit="marquee_forever"
        android:singleLine="true"
        
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
  1. MainAC setting selected
class MainActivity : AppCompatActivity() {
    
    
    override fun onCreate(savedInstanceState: Bundle?) {
    
    
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        Run_textid.isSelected=true
    }
}

Insert picture description here

2. Kotlin1.3kts only has view binding

3. AS File setting kotlin1.6->1.8 will not report an error

Guess you like

Origin blog.csdn.net/qq_38304672/article/details/112848505