我在我的Android应用程序中使用了progressDialog,我使用了代码
ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setCancelable(false);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setMessage("Please wait to get contacts");
progressDialog.setProgress(0);
progressDialog.show();
我想更改邮件字体大小,并希望在邮件中添加一些颜色吗?
答案 0 :(得分:9)
以编程方式更改Android中的ProgressDialog消息字体大小:
String s= "Hello";
String title="MyTitle";
SpannableString ss1= new SpannableString(title);
ss1.setSpan(new RelativeSizeSpan(2f), 0, ss1.length(), 0);
ss1.setSpan(new ForegroundColorSpan(Color.RED), 0, ss1.length(), 0);
SpannableString ss2= new SpannableString(s);
ss2.setSpan(new RelativeSizeSpan(2f), 0, ss2.length(), 0);
ss2.setSpan(new ForegroundColorSpan(Color.GREEN), 0, ss2.length(), 0);
ProgressDialog pd = new ProgressDialog(this);
pd.setTitle(ss1);
pd.setMessage(ss2);
pd.show();
答案 1 :(得分:3)
private ProgressDialog Dialog = new ProgressDialog(currentfile.this);
Dialog.setMessage(Html.fromHtml("<font color='white' ><big>"
+ "Downloading ..." + "</big></font>"));
Dialog.show();
答案 2 :(得分:0)
制作如下所示的自定义进度对话框:
custom_progress_dialog.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@null"
>
<TextView
android:id="@+id/animation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/string"
android:size="30dp" />
</LinearLayout>
MyCustomProgressDialog.java
public class MyCustomProgressDialog extends ProgressDialog {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.custom_progress_dialog);
...
}
public static MyCustomProgressDialog ctor(Context context) {
MyCustomProgressDialog dialog = new MyCustomProgressDialog(context);
dialog.setIndeterminate(true);
dialog.setCancelable(false);
return dialog;
}
@Override
public void show() {
super.show();
}
@Override
public void dismiss() {
super.dismiss();
}
}
然后在asynctask中使用进度对话框类,如下所示:
class DemoAsyncTask extends AsyncTask<Void, Void, Void> {
private final MyCustomProgressDialog progressDialog;
public DemoAsyncTask(Context ctx) {
progressDialog = MyCustomProgressDialog.ctor(ctx);
}
@Override
protected void onPreExecute() {
super.onPreExecute();
textView.setVisibility(View.INVISIBLE);
progressDialog.show();
}