I have used progressDialog in my android application and i have used code as
ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.se
Make custom progress dialog like below:
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();
}
}
and then use progress dialog class in asynctask like below:
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();
}
private ProgressDialog Dialog = new ProgressDialog(currentfile.this);
Dialog.setMessage(Html.fromHtml("<font color='white' ><big>"
+ "Downloading ..." + "</big></font>"));
Dialog.show();
Change the ProgressDialog Message font size in android programmatically:
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();