gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 02:29:42 27 4
gpt4 key购买 nike

在我的 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com