I have a hindi content based android app and have used devangiri font from Android API 16 SDK and renamed as hindi.ttf. The text renders fine on API level 16 and 17 but simply tears apart in Android API level 15 and lower.
Is there any why I can fix that without removing support for lower API levels. My code for setting textview is:
import android.app.Activity;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.GestureDetector;
import android.widget.TextView;
public class Prayer extends Activity {
// TextSwitcher vs;
GestureDetector gestureDetector;
static Tips tip = null;
static StringBuilder quesString = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.prayer);
TextView tv1 = (TextView) findViewById(R.id.textView1);
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/hindi.ttf");
tv1.setTypeface(tf);
tv1.setText("श्री");
tv1.setPaintFlags(tv1.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
}
}
Layout XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#C5C6E1"
tools:context=".Prayer" >
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</TextView>
</RelativeLayout>
Current:
Expected: