Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i use bangla font as a string value in android

how can i use bangla font in a android app as a string value in my string.xml file and also read in my UI.Advance thanks to answer

like image 686
Nahid Avatar asked Jun 21 '11 04:06

Nahid


1 Answers

First open assets folder and create a new folder named font and then put Rupali.ttf in the fontfolder.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView
        android:id="@+id/DefaultFontText"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize="30sp"
        android:text="Here is some text." />
    <TextView
        android:id="@+id/CustomFontText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="30sp"
        android:text="ডিরেক্টর মমনক(!?) করতেছি অন্তত ঘড়িটা যেন বানাতে পারি আমি চেষ্টা করছি">
        </TextView>
</LinearLayout>

And,

package com.amader;

import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TextView;

public class Fonts extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Typeface tf = Typeface.createFromAsset(getAssets(),
                "font/Rupali.ttf");
        TextView tv = (TextView) findViewById(R.id.CustomFontText);
        tv.setTypeface(tf);
    }
}

Shortcoming: All bangla combined words does not work properly. If anybody has the solution please let me know.

like image 73
Nahid Avatar answered Oct 28 '22 10:10

Nahid