I have an application that is always in landscape view. My AlertDialog windows are of the desired height, but are too narrow. See below,
Code from this fragment is:
private void changeSpeciesNoticeDialog() {
AlertDialog.Builder changeSpeciesNoticeDialog = new AlertDialog.Builder(getActivity());
View v = this.getLayoutInflater().inflate(R.layout.change_species, null);
changeSpeciesNoticeDialog.setView(v);
final AlertDialog alert = changeSpeciesNoticeDialog.create();
TextView tvShowSpecies = v.findViewById(R.id.tvchangedfieldlabelxml);
tvShowSpecies .setTypeface(null, Typeface.BOLD);
tvShowSpecies .setText(szSpecies);
alert.setView(v);
alert.show();
}
XML code is:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tvchangedfieldlabelxml"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backgroundTint="@color/yellow"
android:gravity="center_horizontal|fill_horizontal"
android:text="Chinook"
android:textColor="@color/black"
android:textSize="80pt"
android:textStyle="bold"
android:textAlignment="center"
tools:layout_editor_absoluteX="11dp"
tools:layout_editor_absoluteY="64dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Finally, note that orientation is set in MainActivity thus,
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
...
}
Thanks in advance.