我创建了一个自定义 DialogFragment,就像开发人员指南中描述的那样。现在我想做的事情听起来很简单,但我无法让它发挥作用。我已经定义:android:background="@android:color/transparent"
在我这样加载的布局 xml 中(在我的 onCreateDialog 中):
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater();
final View view = inflater.inflate(R.layout.pausedialog, null);
setStyle(STYLE_NO_FRAME, R.style.CustomDialog);
如您所见,我还尝试在 DialogFragment 中设置自定义样式,其定义如下:
<style name="CustomDialog" parent="android:style/Theme.Dialog">
<item name="android:windowBackground">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:alwaysDrawnWithCache">false</item>
<item name="android:windowContentOverlay">@null</item>
</style>
而且我还尝试getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(0));
了导致空指针异常的方法。
我正在使用android.support.v4.app.DialogFragment
. 这可能是原因吗?还是我做错了什么?