Textview自动换行不在RelativeLayout中的空间上
我在RelativeLayout中有一个TextView,它只是不断地在单词中间剪切文本。
该行为的原因是什么?
我所拥有的:
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="-35dp" >
<TextView
android:id="@+id/txtThema_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/txtThema_titel"
android:paddingLeft="15dp"
android:paddingRight="10dp"
android:scrollHorizontally="false"
android:text="Some random text that will be longer than this text. Data comes from SQLite-Database" />
</RelativeLayout>
它产生的结果:
Some random text that wil
l be longer than this
text. Data comes from SQL
ite-Database
有些单词位于下一行,例如本例中的“文本”,有些单词在单词中的某个位置被剪切。
我的文本来自 SQLite 数据库,当我使用静态文本时,换行没问题。
我可以检查我的文本什么?这些空间看起来就像普通空间一样...... 填充不会改变任何东西。
更新 在花了一些时间检查看起来像空格的字符后,我终于在 http://www 上找到了相应的十六进制代码。 ascii-code.com/
使用replaceAll问题就消失了
string = string.replaceAll("\\u00a0"," ");
也许有人知道避免TextView不同行为的好方法......
I have a TextView in a RelativeLayout which just keeps cutting the text in the middle of the word.
What is the reason for the behavior?
What I have:
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="-35dp" >
<TextView
android:id="@+id/txtThema_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/txtThema_titel"
android:paddingLeft="15dp"
android:paddingRight="10dp"
android:scrollHorizontally="false"
android:text="Some random text that will be longer than this text. Data comes from SQLite-Database" />
</RelativeLayout>
What it produces:
Some random text that wil
l be longer than this
text. Data comes from SQL
ite-Database
Some words are on the next line like 'text' in this example, some get cut somewhere in the word.
My text comes from an SQLite-database, when I use static text the wrapping is ok.
What can I check my text for? The spaces look like regular spaces...
The padding does not change anything.
UPDATE
After spending some time checking the character which looks like a space I finally found the correspindonding hex code on http://www.ascii-code.com/
The problem went away using replaceAll
string = string.replaceAll("\\u00a0"," ");
Maybe someone knows a good way to avoid the behavior for the TextView different...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论