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>