2016-03-18 19 views
0

Ich versuche einen scrollbaren TextView zu erstellen, wo der Benutzer die Aktualisierungen scrollen kann.Scrollbare Textansicht funktioniert nicht

ich das versucht:

XML:

<TextView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:textAppearance="?android:attr/textAppearanceSmall" 
    android:text="" 
    android:scrollbars="vertical" 
    android:id="@+id/updateText" 
    android:background="#ce000000" 
    android:textColor="#FFF" 
    android:padding="12dp" 
    android:textSize="13sp" /> 

und der Code:

text.setMovementMethod(new ScrollingMovementMethod()); 
text.setText(updates.get(position).getUpdateText()); 

Doch es nicht richtig funktioniert.

Es ist laggy. Manchmal funktioniert es, aber meistens nicht.

Kann jemand helfen?

+0

Haben Sie versucht, die 'TextView' in einem' ScrollView' nur darum? – NoChinDeluxe

+0

@NoChinDeluxe Ja, ich tat, aber es ist immer noch laggy –

Antwort

0

den nachstehenden Attribute an Ihren Textview

android:maxLines = "20" // any number 
android:scrollbars = "vertical" 

Auch setMovementMethod() -

text.setMovementMethod(new ScrollingMovementMethod()); 
+0

Ich meine nicht, es funktioniert nicht. Aber es ist zu lückig, es dauert etwa 5-7 Scrolls und mit einem bestimmten Winkel, 1 Scroll zu tun –

0

Ich empfehle Ihnen, eine Scroll zu verwenden und dann in diesem Textview setzen.

<ScrollView 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
xmlns:android="http://schemas.android.com/apk/res/android"> 

<TextView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:textAppearance="?android:attr/textAppearanceSmall" 
    android:text="" 
    android:scrollbars="vertical" 
    android:id="@+id/updateText" 
    android:background="#ce000000" 
    android:textColor="#FFF" 
    android:padding="12dp" 
    android:textSize="13sp" />