Well, so that we are in tune, my idea is to create a logger
I've already managed to make it scroll vertically but
as I do not fit the text in TextView
I share the code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="@+id/edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:hint="texto" />
<Button
android:id="@+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="enviar"
app:layout_constraintTop_toBottomOf="@id/edit"/>
<TextView
android:id="@+id/test1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="4"
android:scrollbars="vertical|horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
JAVA:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity);
final TextView textView = (TextView) findViewById(R.id.test1);
Button but=(Button) findViewById(R.id.send);
final EditText edit=(EditText) findViewById(R.id.edit);
textView.setMovementMethod(new ScrollingMovementMethod());
but.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String text=edit.getText().toString();
textView.append("\n"+text);
}
});
}
}
RESULT:
and that's how vertical scroll works but not horizontal
SUCCESSFUL ANSWER
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/test1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="4"
android:scrollbars="vertical" />
</LinearLayout>
</HorizontalScrollView>
but : being wrap_content the size of the textview is not the best to facilitate vertical movement