android - 在 Android 的横向模式中,对话框未全屏显示。

标签 android android-layout android-dialog

在我的 OnListItemClick 上,我正在显示一个工作正常的 Dialog,即全屏显示 < strong>Portrait Orientation 使用自定义对话框布局。为了支持 LandScape Orientation,我在 layouts-land 文件夹中添加了自定义布局,设备正在选择该布局。但是对话框没有水平全屏显示。它唯一的填充垂直屏幕。

    final Dialog prfDialog = new Dialog(getActivity());
    prfDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    prfDialog.setContentView(R.layout.view_student_dailog_layout);
    prfDialog.getWindow().setBackgroundDrawableResource(R.drawable.dialoge_back);

这是我的布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/editStudentMainLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

             // Other View

</RelativeLayout>

最佳答案

创建另一个扩展 Dialog 的类,并添加它

    @Override
public void onStart()
{
    super.onStart();
    Dialog dialog = getDialog();
    if (dialog != null)
    {
        int width = ViewGroup.LayoutParams.MATCH_PARENT;
        int height = ViewGroup.LayoutParams.MATCH_PARENT;
        dialog.getWindow().setLayout(width, height);
    }
}

这将强制对话框全屏显示。

也许如果您想这样做,只需在创建对话框后使用该方法即可。

关于android - 在 Android 的横向模式中,对话框未全屏显示。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27468196/

相关文章:

android - onReceive 中的对话框抛出异常 : unable to add window -- token null is not

android - 创建对话作为 Activity ?

android - 检测我的应用程序自己的android :versionCode at run time

android - 错误构建 APK QT Creator - 构建 android 包失败

Android 使进度对话框不可关闭

java - TextView没有显示结果

Android:允许 TableLayout 中的边距/填充以在小部件之间进行一些分隔

java - (EditText)Android 联系人列表获取电话号码

android - 主页图标向上指示器兼容操作栏

android - 以编程方式为自定义对话框设置动画