ScrollView does not scroll up

1

I am trying to generate a message sale that scrolls down as I insert text in a% multiline% code, but the% co_of% does not work when I try to move it up to see the previous messages.

<ScrollView
    android:id="@+id/idChat"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="vertical"
    android:fillViewport="true">

       <TextView
            style="@style/chat"
            android:id="@+id/textoChat"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:maxLines="50"
            android:text="" />

</ScrollView>

And the logical part:

public void mensaje (View vista){
    String msg = getResources().getString(R.string.msg1);
    Chat(msg + System.getProperty ("line.separator"));
}

public void Chat(String msg){
    TextView lista = findViewById(R.id.textoChat);
    lista.append(msg);

}
    
asked by M.J.D 01.04.2018 в 14:24
source

1 answer

0

Actually you already have a ScrollView for this purpose,

<ScrollView
    android:id="@+id/idChat"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="vertical"
    android:fillViewport="true">

       <TextView
            style="@style/chat"
            android:id="@+id/textoChat"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:maxLines="50"
            android:text="" />

</ScrollView>

If the content within the ScrollView in this case the Text within the TextView does not have enough content, the ScrollView is not activated.

and it is only shown when the content is greater than the area of your ScrollView and you apply and perform "scroll". It is not necessary to add the android:scrollbars="vertical" property since the "scroll" bar is activated automatically.

    
answered by 02.04.2018 в 23:13