简体   繁体   English

Android文本会在某些设备上被剪裁

[英]Android text gets clipped on some devices

I am facing an issue in one phone (till yet). 我在一部手机中面临一个问题(直到现在)。 My app uses Hindi fonts. 我的应用使用印地语字体。 It shows well on emulator, tab, many other phones too. 它在模拟器,标签,许多其他手机上也很好用。 But one of the phone which I am using for testing purpose is showing the text going cut from sides. 但是我用于测试目的的一部手机正在显示从侧面切割的文字。

I tried almost everything for putting it in the right order but none worked. 我尝试了几乎所有的东西,因为它按正确的顺序排列,但都没有用。 Here posting the screenshots of two of my test phones and the text. 这里张贴了我的两部测试手机和文字的截图。

The screenshot with error: 错误的屏幕截图:

http://virtualcolors.net/akki/stmd/error.jpg

The screenshot of other phones: and the expected one too: 其他手机的截图:以及预期的手机:

http://virtualcolors.net/akki/stmd/correct.jpg

What could be the reason and how can I solve it? 可能是什么原因,我该如何解决? Please let me know!! 请告诉我!!

TextView configs I am using: 我使用的TextView配置:

<TextView
    android:id="@+id/A_lbl_mandir"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:text="@string/Abt_mandir"
    android:textAlignment="center"
    android:textColor="#80000A"
    android:textSize="35sp" />

EDIT: My complete activity 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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<TextView
    android:layout_width="wrap_content"
    android:id="@+id/text"
    android:layout_height="wrap_content"
    android:textSize="20sp"
    android:text="@string/hello_world" />
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:layout_below="@id/text" >
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="20sp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:padding="5sp"
    android:text="@string/test"/>
</ScrollView>

</RelativeLayout>

I have tried and deleted many other things especially for this phone. 我试过并删除了许多其他东西,尤其是这款手机。 But unable to solve the issue! 但无法解决问题!

this occurs in 4.1.2 and its documented as a bug in Google which they have fixed in 4.2. 这发生在4.1.2中,并记录为谷歌中的一个错误,他们已在4.2中修复。

https://code.google.com/p/android/issues/detail?id=34432 https://code.google.com/p/android/issues/detail?id=34432

This happens with unicode fonts where the Android OS is not able to calculate the length of the text. 这种情况发生在unicode字体中,其中Android OS无法计算文本的长度。

All right! 行! Found another phone with same issue. 找到另一部同样问题的手机。 In that phone too, the text was clipped. 在那部手机中,文字也被剪裁了。 I guess there is some problem with the phone. 我猜电话有问题。 Because even popular apps like Whatsapp has got the same problem on that device. 因为即使像Whatsapp这样的热门应用也在该设备上遇到了同样的问题。 The Hindi text was cut same as shown in the images above. 印地语文本被剪切为与上图中所示相同。

Possible fix for that issue: (if someone gets that n what I am doing now.) I realised that browser shows the hindi fonts well on that. 可能解决了这个问题:(如果有人得到了我现在正在做的事情。)我意识到浏览器显示了hindi字体。 So better make a native app on html, javascript especially for such devices and view the HTML using WebView.The application will get a little slow but we have to do it Until we get the actual problem creating it. 因此,最好在html,javascript上制作本机应用程序,尤其是对于此类设备,并使用WebView查看HTML。应用程序将变得有点慢,但我们必须这样做直到我们得到实际问题创建它。

Please note: this is not a solution, but a fix to make that work. 请注意:这不是一个解决方案,而是一个解决方案,使这项工作。 Better known as "JUGAAD" in hindi. 在印地语中被称为“JUGAAD”。

try this. 试试这个。

<ScrollView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_below="@id/text" 
android:padding="5dp">
<TextView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:textSize="20sp"
  android:gravity="left" 
  android:padding="5sp"
  android:text="@string/test"/>
</ScrollView>

On some phones (specially on Samsung ones) some custom fonts are cuted off (or clipped). 在某些手机上(特别是在三星手机上),某些自定义字体会被删除(或剪裁)。 I had this with custom italic font. 我有自定义斜体字体。 Some say that you can edit font to add some kind of padding (i can't confirm that because my lack of knowledge of editing fonts) but: - EditText/TextView add some padding from xml - Ellipsize (on some devices messing with this helps displaying text correctly) 有人说你可以编辑字体来添加某种填充(我无法确认,因为我缺乏编辑字体的知识)但是: - EditText / TextView从xml添加一些填充 - Ellipsize(在某些设备上弄乱这有助于正确显示文字)

Also could you post screenshot with enabled developer options to draw layout bounds, this could help to resolve your problem if above solutions won't help 您也可以使用已启用的开发人员选项发布屏幕截图来绘制布局边界,如果上述解决方案无法解决问题,这可能有助于解决您的问题

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

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