Disable Word Wrap in an Android Multi-Line TextView

后端 未结 4 1461
小鲜肉
小鲜肉 2020-12-29 20:50

I am working on a Month View with an advanced swipe (requires current, next and previous to be loaded to allow each view to stick to your finger) which means I have many vie

相关标签:
4条回答
  • 2020-12-29 21:26

    in java code

    textView1.setMovementMethod(new ScrollingMovementMethod());
    

    in XML file

    android:minLines="5"
    

    does the trick.

    0 讨论(0)
  • 2020-12-29 21:31

    In Java:

    setHorizontallyScrolling(boolean) 
    

    In theory, android:scrollHorizontally should do the same in XML, but there is a bug in android that stops it working.

    0 讨论(0)
  • 2020-12-29 21:45

    Currently the best answer for XML is

    android:maxLines="1"
    

    Because android:singleLine is now depreciated

    0 讨论(0)
  • 2020-12-29 21:52

    android:singleLine-----this is for xml

    setTransformationMethod(TransformationMethod)-----this is for java

    Constrains the text to a single horizontally scrolling line instead of letting it wrap onto multiple lines, and advances focus instead of inserting a newline when you press the enter key.

    I'm not sure if this will work, but it worked for me when I wanted my TextView not to wrap in my ListView

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