面对问题的好日子,我无法删除ProgressDialog
后面的白色背景。我正在尝试将background=#00FFFFFF
用于RelativeLayout
,但没有结果。如何删除此背景或使其透明?
我的ProgressDialog
代码:
public class Loading {
private Context context;
private ProgressDialog dialog;
public Loading(Context context) {
this.context = context;
}
public void show() {
getDialog().show();
getDialog().setContentView(R.layout.dialog_spinner);
}
public void dismiss() {
if (dialog != null) {
dialog.dismiss();
}
}
public void error() {
dismiss();
}
public void success() {
dismiss();
}
public void error(RetrofitError error) {
EventBus.getDefault().post(error);
}
public ProgressDialog getDialog() {
if (dialog == null) {
dialog = new ProgressDialog(context);
dialog.setCancelable(true);
dialog.setCanceledOnTouchOutside(false);
}
return dialog;
}
}
dialog_spinner布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/dialog_progress_background">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:orientation="horizontal">
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Loading..."
android:textColor="#FFFFFF" />
</LinearLayout>
</RelativeLayout>
和dialog_progress_background形状:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="10dp" />
<solid android:color="#80000000" />
</shape>
答案 0 :(得分:3)
添加以下代码
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
getDialog().setContentView(R.layout.dialog_spinner);
我希望它适合你。