需要自定义样式:
<style name="myDialog" parent="@android:style/Theme.Dialog"> <item name="android:windowFrame">@null</item> <item name="android:windowIsFloating">true</item> <item name="android:windowContentOverlay">@null</item> <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item> <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item> </style> <style name="myProgressDialog" parent="@style/myDialog"> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowNoTitle">true</item> </style>
然后在带样式参数的构造方法中设置样式:
public SimpleProgressDialog(Context context) { super(context, R.style.myProgressDialog); this.context = context; this.setIndeterminate(true); this.setCancelable(true); this.getWindow().setGravity(Gravity.CENTER); }