问题
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