prevent undesired line wrapping in TextView

后端 未结 3 1027
小鲜肉
小鲜肉 2021-02-07 00:00

My textview is wrapping text despite the settings lines=\"1\" and ellipsise=\"end\". What do I need to do in addition to prevent the line wrapping hand

相关标签:
3条回答
  • Add the following to your TextView definition:

    android:maxLines="1"
    
    0 讨论(0)
  • 2021-02-07 00:18

    The option shown below is deprecated

    android:singleLine="true"
    

    Instead use this:

    android:maxLines="1"
    
    0 讨论(0)
  • 2021-02-07 00:22

    From TextView Ellipsize (...) not working :

     <TextView android:id="@+id/lName"
          android:style="@style/autoscroll" />
    

    And in your style.xml

     <style name="autoscroll">
        <item name="android:singleLine">true</item>
        <item name="android:ellipsize">marquee</item>
        <item name="android:marqueeRepeatLimit">marquee_forever</item>
        <item name="android:focusable">true</item>
        <item name="android:focusableInTouchMode">true</item>
        <item name="android:scrollHorizontally">true</item>
    </style>
    
    0 讨论(0)
提交回复
热议问题