Android Display Long Long Text
I'm working on this case for several days. I have a file with 20 thousands lines text to be displayed in an activity. I use a TextView in a ScrollView to display the text. Everythi
Solution 1:
For that task I've developed a library (class) called LongTextView
: https://github.com/metalurgus/LongTextView
Usage:
<com.metalurgus.longtextview.LongTextView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:gravity="left|top"
app:maxLinesPerItem="2"
app:text="@string/long_text"
app:textColor="#ff0000"
app:textSize="5dp" />
How it works:
It splits whole text into parts, and shows it as a ListView
items using recycling, and therefore - with no UI lag and OOM due to enormous TextView
Solution 2:
You need to set the hardware acceleration as false in your manifest.xml file as mentioned here - https://stackoverflow.com/a/12118798/1649353
Or try like this
Viewscroll= layout.findViewById(R.id.scrollView1);
scroll.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
Solution 3:
Try this:
TextViewtxtDetails= (TextView) findViewById(R.id.txtDetails);
txtDetails.setText("Your Text");
txtDetails.setMovementMethod(newScrollingMovementMethod());
From here: https://stackoverflow.com/a/11589827/6437300
Post a Comment for "Android Display Long Long Text"