2

複数の言語で SMS アプリを作成しています。ヒンディー語の場合、DroidHindi.ttf ファイルを assets/fonts フォルダーに含めました。これを使用して、テキストビューとボタンにこれを実装できます:-

Typeface face;       
face = Typeface.createFromAsset(this.getAssets(), "fonts/DroidHindi.ttf");
TextView font1 = (TextView) findViewById(R.id.tv1font);
font1.setTypeface(face, Typeface.BOLD); 
TextView font2 = (TextView) findViewById(R.id.tv2font);
font2.setTypeface(face, Typeface.BOLD); 
Button bfont = (Button) findViewById(R.id.btnsend);
bfont.setTypeface(face, Typeface.BOLD); 

そして、それは完全に正常に機能しています。

ただし、トースト メッセージを表示している間は実装できません。

Toast.makeText(getBaseContext(), R.string.toast_msg ,Toast.LENGTH_SHORT).show();

このコードに加えて、DroidHindi.ttf ファイルを実装する必要があります。

それを行う方法はありますか?

4

2 に答える 2

1
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.custom_toast,
                               (ViewGroup) findViewById(R.id.toast_layout_root));

TextView text = (TextView) layout.findViewById(R.id.text);
text .setTypeface(face, Typeface.BOLD); // set your typeface here just like you have done above
text.setText("This is a custom toast");

Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();
于 2013-01-31T07:28:21.117 に答える