Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Max 9000 characters in Android TextView?

I have items with a lot of text, mostly around 8500 to 9500 characters. I want to display that in a scrollable textview, but when put the text in a TextView, it seems to be truncated to a max of 9000 characters, while a (the original) String object can hold more. Is there a way to extend this number? Absolutely no parameters on restricting the size of the TextView has been set. Thanks in advance.

like image 411
Harreld Kuiper Avatar asked Aug 09 '11 13:08

Harreld Kuiper


3 Answers

Here is a link which basically says:

The answer is "how much memory can you allocate?" Of course the system needs to allocate resources to measure and typeset and render all of that text. If it's too long, consider showing the text in pages or chunks.

So if your string has 50000 characters, show it in 9000 character chunks.

like image 123
Jack Avatar answered Nov 03 '22 03:11

Jack


Use this on your EditText or TextView:

android:maxLength="1000000"

Some phones have an hard limit of 9000 chars by default.

like image 4
André Restivo Avatar answered Nov 03 '22 04:11

André Restivo


For anyone looking at this in 2018, I don't think there's a hard limit. I have a pretty cheap Android phone with 1 GB of RAM and was able to both edit and display over 40,000 characters of text. There is a slight initial pause when pasting into the edit box and when rendering into a text view but otherwise it works just fine.

like image 1
Eric Mutta Avatar answered Nov 03 '22 02:11

Eric Mutta