我必须将项目的字体更改为外部字体,我几乎无处不在,现在只有它缺少ProgressDialog和ErrorDialeg的标题(正文也被更改)。
所以我在两种情况下都做了(由于Exception而发表了文本视图):
String msg1 = "one", msg2 = "two";
progressDialog = ProgressDialog.show(activity, msg1, msg2, true);
Typeface font=Typeface.createFromAsset(activity.getAssets(),"fonts/rockwell.ttf");
TextView text = (TextView)progressDialog.findViewById(android.R.id.message);
text.setTypeface(font);
//text = (TextView)progressDialog.findViewById(android.R.id.title);
text.setTypeface(font);
和
..........
AlertDialog dialog = new AlertDialog.Builder(a)
.setTitle( titol )
.setMessage( cos )
..........
.show();
//Establir el canvi de font a la personalitzada.
Typeface font=Typeface.createFromAsset(a.getAssets(),"fonts/rockwell.ttf");
TextView textView = (TextView)dialog.findViewById(android.R.id.message);
textView.setTypeface(font);
//textView = (TextView)dialog.findViewById(android.R.id.title);
textView.setTypeface(font);
textView = (TextView)dialog.findViewById(android.R.id.button1);
textView.setTypeface(font);
我已经尝试了所有可能的选项(不仅仅是'R.id.title')而且我只有Exceptions试图在两种情况下都获得TITLE TextView。这是我需要改变整个项目字体的最后一件事。 如果有人知道从哪里获得标题...... 提前谢谢。
答案 0 :(得分:7)
for AlertDialog试试这个:
((TextView) dialog.findViewById(getResources().getIdentifier(
"alertTitle", "id", "android"))).setTypeface(myRegularFont);
对于AlertDialog Button TypeFace:
((Button) dialog.getButton(AlertDialog.BUTTON_POSITIVE))
.setTypeface(myBoldFont);
for ProgressDialog试试这个:
((TextView) prWait.findViewById(getResources().getIdentifier(
"alertTitle", "id", "android"))).setTypeface(myRegularFont);