我想Dialog
圓角,但是當Dialog
看到有下方的矩形見過下面的角落,像這樣:的Android AlertDialog圓角:矩形看到下面的角落
我建立使用自定義DialogFragment
的dialog
:
public class MyDialogFragment extends DialogFragment{
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater();
builder.setView(inflater.inflate(R.layout.playdialog, null));
return builder.create();
}
}
對話框佈局(playdialog)具有以下可繪製背景:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<solid
android:color="#AAAAAAAA" />
<stroke
android:width="2dp"
android:color="#FF000000" />
<corners android:radius="20dp" />
</shape>
正如我所說的,我設置繪製背景:
android:background="@drawable/dialog_background"
我不希望這樣的矩形待觀察。我該怎麼做??
在this後用戶有同樣的問題。我試圖使用爲他工作的解決方案,但它並不適合我。我修改了DialogFragment
這樣的:
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater();
builder.setView(inflater.inflate(R.layout.playdialog, null));
Dialog d = builder.create();
d.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
return d;
}
結果是完全一樣的。我怎樣才能刪除矩形?
謝謝!