0

I would like to have a button with 2 lines of text and if text is longer than 2 lines and size of maxWidth, the text should fit into the button borders.

android:maxLines="2"

doesn't work

Any tips?

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
CallMePedro
  • 51
  • 3
  • 19
  • please put more code. – Viral Patel Nov 20 '19 at 11:18
  • 1
    Does this answer your question? [Write Multiline Text on Button in Android](https://stackoverflow.com/questions/19699776/write-multiline-text-on-button-in-android) – PPartisan Nov 20 '19 at 11:18
  • Answered [here](https://stackoverflow.com/questions/8103776/how-can-i-display-multiple-lines-of-text-on-a-button) – Ali Nov 20 '19 at 11:19

2 Answers2

1

Use something like:

<com.google.android.material.button.MaterialButton
    android:layout_width="150dp"
    android:layout_height="wrap_content"
    android:maxLines="2"
    ../>

enter image description here

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
1

Android normal Button widget not having as such functionality.

You have to use the android new library

implementation 'com.google.android.material:material:1.0.0-beta01'

Here is the reference.

@Gabriele Mariotti Already define the one way to use of it.

Sunny
  • 3,134
  • 1
  • 17
  • 31