我的应用正在进行日志记录,用户可以将其运行数天。在这种情况下,我可能会有100k行文本,你可以滚动。
这似乎不合理。我应该看到一些内存限制。你最多会保留多少行文字?
你能否拥有一个滚动的文本视图,可以保留最后1k行的文本?我应该只使用最大值为1k的textview和滚动条吗?
目前我有以下xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.narb.log.MainActivity">
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Start"
/>
<ScrollView
android:id="@+id/sv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_below="@id/btn"
>
<TextView
android:id="@+id/txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is the log number"
android:layout_margin="15dp"
/>
</ScrollView>
</RelativeLayout>
答案 0 :(得分:0)
如果我是你,我会将最大行设置为100并在文本末尾添加一个更多的读取选项,当用户点击它时,我会将最大行设置为textview.maxlines + 100并隐藏当没有更多文字要显示时,阅读更多。