如何在滚动视图中单独添加描述?



如何在滚动视图中创建描述? 我想在 none 行上放置一个日期,在单独的行上放置一个标题,但即使有空格并按 Enter 键,它也会在一行上创建所有日期。

代码运行良好,我只需要帮助才能控制我在哪一行写的内容。例如

日期 位置 标题 满期

而不是将它们写在单独的行上,而是都写在同一行上。即使使用回车符、制表符、空格。

主要活动

TextView mTitleWindow = (TextView) findViewById(R.id.titleWindow);
TextView mMessageWindow = (TextView) findViewById(R.id.messageWindow);
mTitleWindow.setText("BATMAN IS PART OF THE DC TRINITY");
StringBuilder stringBuilder = new StringBuilder();
String someMessage = "hello     hi" ;
stringBuilder.append(someMessage);
mMessageWindow.setText(stringBuilder.toString());

布局

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/titleWindow"
android:layout_width="352dp"
android:layout_height="58dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="16dp" />

<TextView
android:id="@+id/messageWindow"
android:layout_width="350dp"
android:layout_height="455dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginEnd="17dp"
android:layout_below="@id/titleWindow" />
</RelativeLayout>
</ScrollView>

您好@D_TECK在字符串变量值中使用""作为消息中的单独行。

String someMessage = "hello     n hi";

最新更新