1

As the title describes, I want to know how how many lines has a button's text in Android.

I know that dinamically, if the button's text is too large, the app cuts the text and makes the button multiline.

The text size depends not only on the screen size (using sp for the text size), but also on the phone text size configuration, so I can't anticipate the text size.

Thats why I want to dinamically know if the button is multiline, so I can change the view layout to display the buttons instead of being in one line, put a button one below the other one.

Any ideas of how to achive that?

Thanks!

IIRed-DeathII
  • 1,117
  • 2
  • 15
  • 34

1 Answers1

2

You can use your_Button_Obj.getLineCount()

public abstract int getLineCount ()

Added in API level 1 Return the number of lines of text in this layout.

http://developer.android.com/intl/es/reference/android/text/Layout.html#getLineCount()

how to use getlinecount() in textview android

Community
  • 1
  • 1
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198