что использовать вместо textview для вывода большого объема текста из БД. при использоване textview приложения тормозит. webview нормально показывает но структура текста пропадает webview показывает без пробелов и отступов
2 ответа
Только что доделал библиотеку, загрузил на Github, jitpack.io:
Добавить репозиторий в build.gradle
:
repositories {
maven { url "https://jitpack.io" }
}
Добавить dependency
в build.gradle
:
dependencies {
compile 'com.github.metalurgus:LongTextView:1.0'
}
В XML
использовать так:
<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" />
Попробуйте так:
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);