在Android中,TextView默认是支持自动换行的。只需要将TextView的属性android:singleLine
设置为false即可。
在XML布局文件中:
在代码中:
TextView textView = findViewById(R.id.textView); textView.setText("This is a long text that will automatically wrap to the next line"); textView.setSingleLine(false);
这样就可以实现TextView的自动换行了。