我如何在 android 应用程序中使用 bangla 字体作为我的 string.xml 文件中的字符串值,并在我的 UI 中读取。提前感谢回答
最佳答案
首先打开assets
文件夹并新建一个名为font
的文件夹,然后将Rupali.ttf
放入font
>文件夹。
<?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>
还有,
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);
}
}
缺点:所有孟加拉组合词不能正常工作。如果有人有解决方案,请告诉我。
关于java - 我如何在android中使用孟加拉字体作为字符串值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6420227/