Arabic font gets cut in Android 4.0

孤街浪徒 提交于 2019-12-07 20:40:23

问题


It's look like wired behaviour of Android 4.0.

In my project there is some Arabic text. While I am running that project in the emulator with Android 4.0 or any version then it looks fine. But when I run it on a real Android 4.0 device then it looks like the text is getting cut from the right side. See the below Screen.

Screen 1: In Emulator

Screen 2: In Real Android 4.0 device

I can't understand why it is happen like this. How can I fix this?

code or row item:

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:orientation="horizontal"
    android:layout_height="wrap_content" android:background="#ffffff">
    <LinearLayout android:orientation="horizontal"
        android:layout_margin="20dp" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:layout_gravity="right|center_vertical"
        android:gravity="right">
        <TextView android:id="@+id/toptext" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:text="Title"
            android:paddingRight="10dp" android:gravity="right" android:textSize="16sp"
            android:textStyle="bold" android:textColor="#000000" />

        <TextView android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:text=" "
            android:paddingRight="15dp" android:gravity="right" android:textSize="16sp"
            android:textStyle="bold" android:textColor="#000000" />

    </LinearLayout>
</LinearLayout>

回答1:


As a working around: Try adding right padding to your views.

I had a similar issue with TextViews in ICS. they were cut from the bottom. Fortunately, Google solved this in Jelly Bean version.




回答2:


Relative layout and right margin should be solutions.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="horizontal" >

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_margin="20dp"
    android:gravity="right"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/toptext"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_marginRight="10dp"
        android:text="Title"
        android:textColor="#000000"
        android:textSize="16sp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/toptextleft"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toLeftOf="@+id/toptext"
        android:gravity="right"
        android:paddingRight="15dp"
        android:text="Title"
        android:textColor="#000000"
        android:textSize="16sp"
        android:textStyle="bold" />
</RelativeLayout>




回答3:


Setting the TextView's android:gravity attribute value to "start" rather than "left" or "right" fixed it for me.



来源:https://stackoverflow.com/questions/11698883/arabic-font-gets-cut-in-android-4-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!