我要讓ProgressDialog透明透明,但我從來沒有成爲透明的它成爲ProgressDialog.How黑色背景可以我這樣做,請幫助如何使ProgressDialog在android系統
這裏是我的ProgressDialog代碼: -
private class LoginAttempt extends AsyncTask<String, Void, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(getActivity(), R.style.MyTheme);
pDialog.setCancelable(false);
pDialog.setProgressStyle(android.R.style.Widget_ProgressBar_Small);
pDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
pDialog.show();
}
這裏是我的style.xml
<style name="MyTheme" parent="android:Theme.Holo.Dialog">
<item name="android:alertDialogStyle">@style/CustomAlertDialogStyle</item>
<item name="android:windowBackground">@color/transparent</item>
<item name="android:textColorPrimary">#FFFFFF</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:textColor">#FFFFFF</item>
<item name="android:textStyle">normal</item>
<item name="android:textSize">12sp</item>
</style>
也
<style name="CustomAlertDialogStyle">
<item name="android:bottomBright">@color/transparent</item>
<item name="android:bottomDark">@color/transparent</item>
<item name="android:bottomMedium">@color/transparent</item>
<item name="android:centerBright">@color/transparent</item>
<item name="android:centerDark">@color/transparent</item>
<item name="android:centerMedium">@color/transparent</item>
<item name="android:fullBright">@color/transparent</item>
<item name="android:fullDark">@color/transparent</item>
<item name="android:topBright">@color/transparent</item>
<item name="android:topDark">@color/transparent</item>
</style>
,這裏是我的結果: - enter image description here
確保你給<顏色名稱= 「透明」>#00000000在colors.xml – Rooban
@Rooban:不需要這一點。 Color.Transparent提供所需值 – Yashasvi