Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
    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:

<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!

like image 269
Akshit Arora Avatar asked Mar 22 '14 12:03

Akshit Arora


2 Answers

this occurs in 4.1.2 and its documented as a bug in Google which they have fixed in 4.2.

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.

like image 158
Sunny Avatar answered Oct 04 '22 18:10

Sunny


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. 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. 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.

Please note: this is not a solution, but a fix to make that work. Better known as "JUGAAD" in hindi.

like image 30
Akshit Arora Avatar answered Oct 04 '22 19:10

Akshit Arora