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