我有一个很简单的问题,但我似乎搞不明白。因此,我有一个相当大的文本视图,我希望有12行文本,每一行都有一个单词。但是,当我在xml中编辑时,它只允许我拥有一个android:text属性。我怎么能这么做?
<TextView
android:id="@+id/textView7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:text="speed"
android:text="air speed"
/>因此,我希望有更多的文本属性,如代码中所示。
发布于 2014-07-06 22:32:19
只需使用换行符\n
<TextView
android:id="@+id/textView7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:text="speed\nair speed" />发布于 2014-07-07 09:12:42
您可以使用HTml.from html标记使用java代码在文本视图中设置,如下所示:
TextView tvInformation = (TextView)findViewById(R.id.tv_information);
tvInformation.setText(Html.fromHtml("<br>"+"</br>" + "row1 text" + "<br>"+"</br>" + "row2 text");类似地,您可以根据需要添加12行或更多行。这
标记用于下一行,因为我们在字符串中使用\n。
https://stackoverflow.com/questions/24600908
复制相似问题