TextView 不显示完整内容
TextView doesn't show full content
我的xml布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.LinearLayoutCompat
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".TestingActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/pt_results"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/blank"/>
<Button
android:id="@+id/get_po_results"
android:onClick="onGetPOResultsClick"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/blank"/>
</LinearLayout>
</ScrollView>
</android.support.v7.widget.LinearLayoutCompat>
我通过 xml 类型资源上的简单 setText 设置 TextView 的文本。
这是此资源:
<string name="r0010">code:0010 \n \n \n \n There will be a lot of text. It must separate lines automatically using spaces between lines.
Showing what ScrollView capable of: \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n That's a lot of lines</string>
我想看类似的内容:
code:0010
[some empty lines]
There will be a lot of text. It must separate lines automatically using spaces between lines
[a lot of empty lines]
That's a lot of lines
但这是我得到的:
(phone screenshot 1) and (phone screenshot 2)(TextView 截断文本)
我的第一个猜测是这都是因为 TextView 容量有限,但我没有找到任何相关信息。
顺便说一句,我看到了这个问题 (it's almost similar to mine) 但我不是这样,因为我将 LinearLayout 包装到 ScrollView
问题是,我需要显示大量文本。也许 TextView 不是我需要的工具? TextView有哪些选择?
尝试使用下面的字符串,从你的代码输出看来你的文本在 ' 字符后没有被读取,所以我刚刚改变了。
that's
和
that\'s
试试下面的字符串
<string name="r0010">code:0010 \n \n \n \n There will be a lot of text. It must separate lines automatically using spaces between lines.
Showing what ScrollView capable of: \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n That\'s a lot of lines</string>
尝试记录字符串以查看是否真的是您的 TextView 正在裁剪文本,或者传递给 TextView 的字符串本身被裁剪,这将向您解释问题
我的xml布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.LinearLayoutCompat
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".TestingActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/pt_results"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/blank"/>
<Button
android:id="@+id/get_po_results"
android:onClick="onGetPOResultsClick"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/blank"/>
</LinearLayout>
</ScrollView>
</android.support.v7.widget.LinearLayoutCompat>
我通过 xml 类型资源上的简单 setText 设置 TextView 的文本。 这是此资源:
<string name="r0010">code:0010 \n \n \n \n There will be a lot of text. It must separate lines automatically using spaces between lines.
Showing what ScrollView capable of: \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n That's a lot of lines</string>
我想看类似的内容:
code:0010
[some empty lines]
There will be a lot of text. It must separate lines automatically using spaces between lines
[a lot of empty lines]
That's a lot of lines
但这是我得到的: (phone screenshot 1) and (phone screenshot 2)(TextView 截断文本)
我的第一个猜测是这都是因为 TextView 容量有限,但我没有找到任何相关信息。
顺便说一句,我看到了这个问题 (it's almost similar to mine) 但我不是这样,因为我将 LinearLayout 包装到 ScrollView
问题是,我需要显示大量文本。也许 TextView 不是我需要的工具? TextView有哪些选择?
尝试使用下面的字符串,从你的代码输出看来你的文本在 ' 字符后没有被读取,所以我刚刚改变了。
that's
和
that\'s
试试下面的字符串
<string name="r0010">code:0010 \n \n \n \n There will be a lot of text. It must separate lines automatically using spaces between lines.
Showing what ScrollView capable of: \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n That\'s a lot of lines</string>
尝试记录字符串以查看是否真的是您的 TextView 正在裁剪文本,或者传递给 TextView 的字符串本身被裁剪,这将向您解释问题