简体   繁体   English

在某些较小的屏幕尺寸下,Malayalam文本在TextView中不可见。 (英文文本没有问题)

[英]Malayalam text goes out of view in TextView, in some smaller screen sizes. (No issues with English text)

I have an application which fetches malayalam text from an RSS feed. 我有一个从RSS提要中获取马拉雅拉姆文字的应用程序。

For the sake of brevity, I will use a simple app with static text to explain my problem. 为了简洁起见,我将使用带有静态文本的简单应用程序来解释我的问题。

Code: 码:

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView textView=(TextView) (findViewById(R.id.textview1));

        String text=" സഭ പരിശുദ്ധമാണെന്ന് വിശ്വാസപ്രമാണത്തിൽ നാം പ്രഘോഷിക്കുന്നു. എന്നാൽ, സഭ പാപികളുടെ ഒരു കൂട്ടായ്മയാണെന്നും, എല്ലാ ദിവസവും ഞങ്ങൾ അവരുടെ പ്രവൃത്തികൾ  കാണുന്നതാണെന്നും നിങ്ങൾ പറഞ്ഞേക്കാം. സഭയിൽ പാപികൾ ഉണ്ടെണ്ടന്നത് സത്യമാണ്. ";
        textView.setText(text);
    }

First of all, when I try to save this file with that malayalam text, I get this Message: 首先,当我尝试使用马拉雅拉姆文本保存该文件时,收到以下消息:

I save as UTF-8 and move on. 我另存为UTF-8,然后继续。 Note that in my actual app, this does not happen, since the text is downloaded. 请注意,由于下载了文本,因此在我的实际应用中不会发生这种情况。

Here is the pretty basic xml 这是漂亮的基本xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="10dp"
 >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textview1"
         />

</RelativeLayout>

And this is what I get: 这就是我得到的:

As you can see, the text view does not wrap text properly (at the ends). 如您所见,文本视图无法正确包装文本(在末尾)。 This happens only in some screen sizes. 仅在某些屏幕尺寸下会发生这种情况。 Otherwise, its fine. 否则,很好。

This thing does not happen with english text. 英文文本不会发生这种情况。

I have tried singleline, ellipsize,different paddings etc..nothing works. 我已经尝试过单行,省略号,不同的填充等。

I feel like this has something to do with encoding, but no Idea what. 我觉得这与编码有关,但与想法无关。

Can someone please shed some light on this ? 有人可以对此有所说明吗?

Well, it seems to be a bug with Android itself: https://code.google.com/p/android/issues/detail?id=38357 . 好吧,这似乎是Android本身的错误: https : //code.google.com/p/android/issues/detail?id=38357

It seems to be fixed in 4.2. 它似乎在4.2中已修复。 I got around it by using a webview instead of a textview, for pre 4.2 devices. 对于4.2之前的设备,我通过使用webview而不是textview解决了它。 The webview rendering is not perfect, but better than the text getting cut off. Webview渲染不是完美的,但是比截断文本更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM