Write a paragraph using textview on Android

后端 未结 2 1442
谎友^
谎友^ 2021-02-14 04:26

I want to write a paragraph as part of my mobile application. How do I go about it?

相关标签:
2条回答
  • 2021-02-14 05:18

    Use \n to break line.

    Example:

    TextView t = findViewById(R.id.text);
    t.setText("This is the first line\nThis is the second line\nThird line...");
    
    0 讨论(0)
  • 2021-02-14 05:25
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <string name="text_with_paragraphs">
            Can this contain a lot of text? Can it contain \n a newline? Yes, it can.
            Adding a 2nd line like this should work.
            It should not cause parsing errors.
        </string>
    <resources>
    

    So you can make a reference to it like:

    android:text="@string/text_with_paragraphs"
    

    Reference: http://www.experts-exchange.com/Programming/Smartphones/Android/Q_27925834.html

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