我能够显示对话框,但无法使其居中并且没有白色背景。如何以编程方式使 ProgressDialog 居中且无背景。谢谢^^
我的想法来自: ProgressDialog spin circle,但我不能使用这个xml。
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:visibility="gone"
android:indeterminateDrawable="@drawable/progress" >
</ProgressBar>
+++++++++ 这是在 onPreExecute() 内部:
pDialog = new ProgressDialog(Main_Activity.this);
pDialog.setMessage("Loading products. Please wait...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.setIndeterminateDrawable(getResources().getDrawable(R.drawable.progress));
pDialog.show();
进度.xml
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" >
<shape
android:innerRadiusRatio="3"
android:shape="ring"
android:thicknessRatio="8"
android:useLevel="false" >
<size
android:height="48dip"
android:width="48dip" />
<gradient
android:centerColor="#00FFFF"
android:centerY="0.50"
android:endColor="#0000FF"
android:startColor="#0000A0"
android:type="sweep"
android:useLevel="false" />
</shape>
</rotate>