inv*_*igo 20 android android-dialogfragment
我试图创建MATCH_PARENT宽度的DialogFragment这样的对话框几乎全屏幕(离开填充周围的边缘为流动的样子).我在Android中看到过这个解决方案Full Screen DialogFragment,但我试图避免将宽度设置为1000dp的黑客攻击.以我目前的布局,我是使用FILL_PARENT或MATCH_PARENT它似乎是设置宽度和高度WRAP_CONTENT.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
Run Code Online (Sandbox Code Playgroud)
我已经将此解决方案用于Dialog(而不是DialogFragment),它按预期工作:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Run Code Online (Sandbox Code Playgroud)
Att*_*tif 37
这对我来说很完美.当扩展DialogFragment
覆盖onCreateView()... impelments所有逻辑
对话框使其全屏只是覆盖此方法
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
// the content
final RelativeLayout root = new RelativeLayout(getActivity());
root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
// creating the fullscreen dialog
final Dialog dialog = new Dialog(getActivity());
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(root);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.YELLOW));
dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
return dialog;
}
Run Code Online (Sandbox Code Playgroud)
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NO_TITLE,android.R.style.Theme_Holo_Light);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
25704 次 |
| 最近记录: |