Reputation: 895
Is there any method to show dialog in landscape mode in landscape activity?
This is my dialog showing code:
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();
By using above code dialog is showing in portrait mode.
Upvotes: 1
Views: 3897
Reputation: 66
OOPs this is little late but can help some other needy.
To achieve this just follow four basic steps
and for your smiley face, kindly have a look below code snippet.
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();
Upvotes: 1