是否有任何方法可以在横向活动中以横向模式显示对话框?
这是我的对话框,显示代码:
Dialog dialog = new Dialog(getActivity());
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_todays_pick_list);
// setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
dialog.show();
通过使用上面的代码,对话框以纵向模式显示。
答案 0 :(得分:1)
OOPs这有点晚,但可以帮助其他有需要的人。
要实现这一点,只需遵循四个基本步骤
对于你的笑脸,请看下面的代码片段。
LayoutInflater inflater = getLayoutInflater();
View dialogView = inflater.inflate(R.layout.dialog_screen, null);
final Dialog dialogShowInfo = new Dialog(mContext);
dialogShowInfo.setContentView(dialogView);
dialogShowInfo.setCancelable(false);
TextView tvInputsValuesAll =
dialogShowInfo.findViewById(R.id.tvInputsValuesAll);
Button btnCncl = dialogShowInfo.findViewById(R.id.btnCncl);
btnCncl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialogShowInfo.dismiss();
}
});
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
Window windowAlDl = dialogShowInfo.getWindow();
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
windowAlDl.setAttributes(layoutParams);
dialogShowInfo.show();