2

這裏是xmlactivity_matches.xml),其顯示在下面的屏幕截圖的輸出在一個EditText對象命名txaMatches如何在Android多行Edittext中加速平滑滾動?

<EditText 
    android:id=      "@+id/txaMatches" 
    android:text=     "" 

    android:scrollbars=    "vertical" 
    android:layout_below=   "@+id/pattern" 
    android:textColor=    "@color/yellow_foreground" 
    android:textSize=    "@dimen/matches_text" 
    android:focusable="false" 
    android:inputType="textMultiLine" 

    android:layout_width=   "wrap_content" 
    android:layout_height=   "wrap_content" 
    android:layout_alignParentStart="true" 
    android:layout_alignParentEnd= "true" 
    tools:ignore=     "LabelFor" 
    android:typeface="monospace" 
    android:focusableInTouchMode="false" 
    android:paddingEnd="@dimen/matches_padding" 
    android:paddingStart="@dimen/matches_padding" 
    /> 

enter image description here

謹以此multilineEditText對象的內容,從而平穩滾動如果用戶在裏面滑動,就會加速。

以下是我填寫txaMatches(使用doInBackground)的方法。這是在Java代碼中唯一的地方,我指的是它(當然我也定義和Java中初始化):

protected void onProgressUpdate(String... progress) 
{ 
    for (int i = 0; i < progress.length; i++) 
    if(progress[i].length() > 1) MatchesActivity.txaMatches.append("\n" + progress[i]); 
    else       MatchesActivity.showLetter("Reading " + progress[i].charAt(0)); 
} 

這是xml來進行一個簡單的變化?我應該使用ListView嗎? EditText應該在ListView之內嗎?

我將不得不編寫一些Java代碼?

鑑於我提供的少量代碼,我不期望很多細節。只是概述谷歌將是一個好的開始。

+1

你有一些相關的問題和答案,請參閱:[Java的解決方案](http://stackoverflow.com/問題/ 29304118/how-to-make-edittext-scrolling-smooth),[webview workaround](http://stackoverflow.com/a/5594713/2668136)和[xml解決方法](http://stackoverflow.com/問題/ 12193482/Android的啓用滾動-上的EditText)。 – Fllo

回答

0

非常容易(感謝Fllo的THIRD link)。 (第一個沒有幫助;第二個重點是Java代碼和ScrollView類,並且比第三個涉及更多,其關注於xml並且對於我的情況是完美的(並且僅需要將txaMatches的類型更改爲TextView):

開始的新代碼的新代碼

<ScrollView 
    android:layout_alignParentStart="true" 
    android:layout_alignParentEnd= "true" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"> 

末,除了關閉標籤

<TextView 
    android:id=      "@+id/txaMatches" 
    android:scrollbars=    "vertical" 
    android:layout_width=   "wrap_content" 
    android:layout_height=   "wrap_content" 
    /> 
</ScrollView>