Android Scrollview-文本视图的行数限制
我的应用程序正在进行日志记录,用户可以让它运行几天。在这种情况下,我可能会有10万行文本,您可以滚动浏览 这似乎不合理。我应该看到一些内存限制。您最多可以保留多少行文本 你能有一个滚动文本视图来维护最后1k行文本吗?我应该只使用一个最大行数为1k的文本视图和滚动条吗 目前,我有以下xml:Android Scrollview-文本视图的行数限制,android,textview,scrollview,limit,Android,Textview,Scrollview,Limit,我的应用程序正在进行日志记录,用户可以让它运行几天。在这种情况下,我可能会有10万行文本,您可以滚动浏览 这似乎不合理。我应该看到一些内存限制。您最多可以保留多少行文本 你能有一个滚动文本视图来维护最后1k行文本吗?我应该只使用一个最大行数为1k的文本视图和滚动条吗 目前,我有以下xml: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.co
<?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>
如果我是你,我会将最大行数设置为100,并在文本末尾添加“阅读更多”选项,当用户单击该选项时,我会将最大行数设置为textview.maxlines+100,并在没有更多文本显示时隐藏“阅读更多”