当TextView显示没有空格的长文本时文本丢失
我的 TextView
及其所有容器已将 layout_height
设置为 wrap_content
。它可以很好地显示带有空格的文本(例如:英语),但对于没有任何空格的文本(例如:日语或只是一些没有空格的长文本),一些文本丢失了。
它似乎可以工作当我附加带有两个空格和一个字母的没有空格的文本
时,正确无误。天哪,我不知道为什么:(
msg += " a";
下面是我的布局。任何帮助将不胜感激!谢谢
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/push_header_bg" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:layout_marginLeft="1dp"
android:layout_marginBottom="0dp"
android:src="@drawable/push_logo" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="40dp"
android:text="@string/app_name"
android:textColor="@android:color/white"
android:textSize="22dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/push_center_bg"
android:orientation="vertical" >
<TextView
android:id="@+id/tv_push_sub_header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/push_sub_header"
android:textSize="20dp"
android:layout_marginTop="10dp"
android:textColor="@android:color/black"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_push"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20dp"
android:text="今日は、何事にもパワフルなエネルギーに満ちている1日。また..."
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:textColor="@android:color/black" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:background="@drawable/push_footer_bg" >
<Button
android:id="@+id/btn_close"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:background="@drawable/button_selector"
android:text="@string/push_btn_close"
android:textColor="@android:color/white"
android:textStyle="bold"
android:padding="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp" />
<Button
android:id="@+id/btn_open"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:background="@drawable/button_selector"
android:text="@string/push_btn_open_app"
android:textColor="@android:color/white"
android:textStyle="bold"
android:padding="10dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp" />
</LinearLayout>
My TextView
and all of its containers was set layout_height
to wrap_content
. It displays text with space in it (eg: English) well but with text without any space (eg: Japanese or just some long text without space in it), some text was lost.
It seems to work correctly when i append that text without space
with two spaces and a letter. Omg i don't know why :(
msg += " a";
Below is my layout. Any help will be appreciated! Thanks you
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/push_header_bg" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:layout_marginLeft="1dp"
android:layout_marginBottom="0dp"
android:src="@drawable/push_logo" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="40dp"
android:text="@string/app_name"
android:textColor="@android:color/white"
android:textSize="22dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/push_center_bg"
android:orientation="vertical" >
<TextView
android:id="@+id/tv_push_sub_header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/push_sub_header"
android:textSize="20dp"
android:layout_marginTop="10dp"
android:textColor="@android:color/black"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_push"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20dp"
android:text="今日は、何事にもパワフルなエネルギーに満ちている1日。また..."
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:textColor="@android:color/black" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:background="@drawable/push_footer_bg" >
<Button
android:id="@+id/btn_close"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:background="@drawable/button_selector"
android:text="@string/push_btn_close"
android:textColor="@android:color/white"
android:textStyle="bold"
android:padding="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp" />
<Button
android:id="@+id/btn_open"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:background="@drawable/button_selector"
android:text="@string/push_btn_open_app"
android:textColor="@android:color/white"
android:textStyle="bold"
android:padding="10dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp" />
</LinearLayout>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试通过本地化来完成此操作,
制作 strings.xml 并将您的日语字符串放在这里
res>values-ja>strings.xml
在您的layout.xml 文件中使用这个“TextValue”。喜欢:
Try to do this thing by localization
make strings.xml and put your Japanese string here
res>values-ja>strings.xml
use this "TextValue" in your layout.xml file. Like:
我不知道我的输出是否正确,因为我不懂日语,,,但我使用 UTF8 形式的日语数据,它显示如下(屏幕截图如下)
在此我执行附加和空格。
I dont know whether my output is correct or not coz i don't know Japanese ,,, but i use Japanese data in UTF8 form and it display like this (screen shot is given bellow)
in this i perform append and space.