2
這裏是xml
(activity_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"
/>
謹以此multiline
EditText
對象的內容,從而平穩滾動如果用戶在裏面滑動,就會加速。
以下是我填寫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代碼?
鑑於我提供的少量代碼,我不期望很多細節。只是概述谷歌將是一個好的開始。
你有一些相關的問題和答案,請參閱:[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