java - 我如何在android中使用孟加拉字体作为字符串值

标签 java android fonts android-widget

我如何在 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/

相关文章:

Java Double Trouble - 如何在不使用 BigDecimal 的情况下确保 4.45 是 4.45?

java - Resteasy异常 "No type information to extract entity with, use other getEntity() methods"

java - 图像加载器 "SkImageDecoder::Factory returned null"

android - ADT Eclipse + Gradle : incomplete BuildConfig. java

android - Android中的自定义字体

java - 如何在 ListView 行中显示较长的 TextView 高度?

java - 从 Java 中运行命令行操作

android - 不保持 Activity 时清除 Intent

java - 使用 iText 替换 PDF 中的字体 (Java)

css - 输入文本框宽度和字体宽度