本文介绍了变化在DialogFragment ProgressDialog的字体字样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以知道是否有可能改变 ProgressDialog
的消息显示的字体字样,在 DialogFragment
?
公共类LoadFromCloudTaskFragment扩展DialogFragment { @覆盖
公共对话框onCreateDialog(捆绑savedInstanceState){
this.progressDialog =新ProgressDialog(this.getActivity());
this.progressDialog.setMessage(progressMessage);
this.progressDialog.setCanceledOnTouchOutside(假); 返回progressDialog;
}
从 ProgressDialog
继承创建一个自定义类可能的途径之一。不过,我想知道有没有更好的选择吗?可悲的是,我们没有 ProgressDialog.Builder
。
一个我曾试图替代的是
@覆盖
公共对话框onCreateDialog(捆绑savedInstanceState){
this.progressDialog =新ProgressDialog(this.getActivity());
this.progressDialog.setMessage(progressMessage);
this.progressDialog.setCanceledOnTouchOutside(假); Utils.setCustomFont(this.progressDialog.findViewById(android.R.id.message),Utils.ROBOTO_LIGHT_FONT); 返回progressDialog;
}
但是,这会给我误差
解决方案
One of the suggested solution is as follow. But I don't think this is a good way. Any further suggestion are very much welcomed.
public class ProgressDialogEx extends ProgressDialog {
public ProgressDialogEx(Context context) {
super(context);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View view = this.findViewById(android.R.id.message);
if (view != null) {
// Shouldn't be null. Just to be paranoid enough.
Utils.setCustomFont(view, Utils.ROBOTO_LIGHT_FONT);
}
}
}
public class LoadFromCloudTaskFragment extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
this.progressDialog = new ProgressDialogEx(this.getActivity());
this.progressDialog.setMessage(progressMessage);
this.progressDialog.setCanceledOnTouchOutside(false);
return progressDialog;
}
这篇关于变化在DialogFragment ProgressDialog的字体字样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!