2017-07-25 66 views
0

我的應用程序正在進行日誌記錄,用戶可以讓它運行數天。在這種情況下,我最終可以獲得可以滾動的10萬行文字。Scrollview - TextView根據行數限制

這似乎不合理。我應該看到一些內存限制。您最多可以維護多少行文字?

你可以有一個滾動的textview,這將保持最後的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

如果我是你,我會設置最大線爲100,將增加在文本的最後一個更多選項,當用戶點擊那個,我會設置最大行數爲textview.maxlines + 100,並且會在沒有更多文本顯示時隱藏閱讀。