Androidのテキストビューで自動改行を実装する方法は?
Androidでは、デフォルトでTextViewは自動改行をサポートしています。android:singleLine属性をfalseに設定するだけでOKです。
XMLのレイアウトファイルにおいて:
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is a long text that will automatically wrap to the next line"
android:singleLine="false"/>
コード内では:
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の自動折り返しが可能になります。