I did some testing. It seems this value is not fixed. It moved up and down each time.
But there are some limits:
- TextView.maxLines is Integer.MAX_VALUE by default (2147483647)
- TextView.maxEms is Integer.MAX_VALUE by default
- Java Strings in general are Integer.MAX_VALUE or half the maximum
heap size
On my first test it worked up to 179 899 characters in a single line.
By adding android:maxLength="10000000"
to the xml I got up to 184 200. But that number worked just once.
With a
line break after every character I got up to about 750 000.
值得注意的是,该文从来就没有消失了。 app倒的是:
Throwing OutOfMemoryError "Failed to allocate a 32 byte allocation
with 0 free bytes and 0B until OOM, target footprint 536870912, growth
limit 536870912" (VmSize 2143664 kB, recursive case)
我使用了一台Pixel 3、APIC29型推导器,其编号为1536 mb ram、256mb heap和以下代码:
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i<750000; i++) {
stringBuilder.append("A
");
}
textView.setText(stringBuilder);
我在文件中找到任何东西。
底线没有 实践 /em> 最大值,今天,电话的记忆也大大增加。