Style For Android Progressdialog
I'm trying to customize ProgressDialog style to have something like that: What I have: I know how to change spinner style and color, but what I didn't understand that is: how to
Solution 1:
try the below Code it works for me:
Put this XML file in drawable folder (dialog_progress_background.xml)
<cornersandroid:radius="10dp" /><solidandroid:color="#80000000" /><paddingandroid:bottom="40dp"android:left="40dp"android:right="40dp"android:top="40dp" />
Dailog layout (R.layout.dialog_spinner.xml)
<?xml version="1.0" encoding="utf-8"?><RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent" ><ProgressBarandroid:id="@+id/progressBar"style="?android:attr/progressBarStyleSmall"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerHorizontal="true"android:layout_centerVertical="true" /><TextViewandroid:id="@+id/textView1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/progressBar"android:layout_centerHorizontal="true"android:layout_marginTop="20dp"android:text="Loading..."android:textColor="#FFFFFF" /></RelativeLayout>
// Class for create custom Progress Dialog
publicclassProgressBuilder {
private Context context;
private Dialog dialog;
publicProgressBuilder(Context context) {
this.context = context;
}
publicvoidshowProgressDialog() {
dialog = new Dialog(context);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setBackgroundDrawable(
context.getResources().getDrawable(
R.drawable.dialog_progress_background));
dialog.setContentView(R.layout.dialog_spinner);
dialog.setCancelable(false);
dialog.show();
}
public TextView getTextView()
{
return (TextView)dialog.findViewById(R.id.textView1);
}
public Dialog getDialog()
{
return dialog;
}
publicvoiddismissProgressDialog() {
dialog.dismiss();
}
}
And call showProgressDialog() method to show Progress Dialog
ProgressBuilder dialog=newProgressBuilder(MainActivity.this);
dialog.showProgressDialog()
//to dismiss the progress dialog
dialog.dismissProgressDialog()
Post a Comment for "Style For Android Progressdialog"