what to use instead of textview to display a large amount of text from the database. when used, the textview of the application slows down. webview normally shows but the structure of the text disappears webview shows without spaces and indents
2 answers
Just completed the library, uploaded on Github , jitpack.io :
Add repository to build.gradle :
repositories { maven { url "https://jitpack.io" } } Add dependency to build.gradle :
dependencies { compile 'com.github.metalurgus:LongTextView:1.0' } In XML use like this:
<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" /> |
Try this:
WebView wv = (WebView) findViewById(R.id.wv); String text = "Hello\nworld!"; wv.loadDataWithBaseURL(null, "<html><body style=\"white-space: pre\">"+ text+ "</body></html>", "text/html", "utf-8",null); |