Marquee using maxLines

后端 未结 2 1584
南方客
南方客 2021-01-19 15:26

How can I have a marquee using MaxLines instead of SingleLine ?

This is my TextView :



        
相关标签:
2条回答
  • 2021-01-19 16:10

    In XML

    <TextView
        android:text="11111111111111111111111111111111111111111111111111111111111111"
        android:id="@+id/text_marquee"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:maxLines="1"
        android:ellipsize="marquee"
        android:marqueeRepeatLimit="marquee_forever"
        />
    

    In Java

    ((TextView)findViewById(R.id.text_marquee)).setHorizontallyScrolling(true);
    ((TextView)findViewById(R.id.text_marquee)).setSelected(true);
    
    0 讨论(0)
  • 2021-01-19 16:31

    You can try using this :

    android:maxLength = "10"
    

    OR

    After setting android:maxLines="1", you have to set your inputType too. So, set your android:inputType="text" and that should do the trick.

    0 讨论(0)
提交回复
热议问题