下面的解決方案對我來說非常合適。
的片段對話框如下圖所示創建樣式:
<style name="dialog_theme" parent="android:Theme" >
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
</style>
創建您的Java類,如下:
public class FiltersDialogFragment extends android.support.v4.app.DialogFragment {
static FiltersDialogFragment newInstance() {
FiltersDialogFragment fragment = new FiltersDialogFragment();
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NORMAL, R.style.dialog_theme);
}
@Override
public void onStart() {
super.onStart();
Dialog d = getDialog();
if (d!=null){
int width = ViewGroup.LayoutParams.MATCH_PARENT;
int height = ViewGroup.LayoutParams.MATCH_PARENT;
d.getWindow().setLayout(width, height);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.dialog_filters, container, false);
return view;
}
}
編碼愉快!
[在Android的全屏DialogFragment](可能的重複http://stackoverflow.com/questions/7189948/full-screen-dialogfragment-in-android) – Distwo