how can I display multiple lines of text on a button

前端 未结 3 460
梦毁少年i
梦毁少年i 2020-12-14 00:18

My button\'s layout_width set to match_parent.

In order to display multi lines on the button, I tried:

  • insert \'\\n\' into the text on button

3条回答
  •  星月不相逢
    2020-12-14 00:33

    If you're trying to add a new line in a layout XML file:

    Use (new line)

        android:text="Hi
    Hello"
    

    If you're trying to add a new line in code, just use '\n', same as in any other text.

    If you can't see the second line, it may be that your Button doesn't have enough height. IE, in my case, the layout containing the button had a fixed height that just happened to make my button perfectly display one line of text.

提交回复
热议问题