N
N
Nikolai2020-06-13 08:43:25
Java
Nikolai, 2020-06-13 08:43:25

How to stretch Dialog to full screen height?

I use Dialog for full screen popup.
In the popup there is a zoomable image ( https://github.com/chrisbanes/PhotoView) and a close button.

I can not remove the status bar to fully enlarge the image.

How to do?

Dialog dialog = new Dialog(holder.itemView.getContext());
dialog.setContentView(R.layout.isu_image_layout);
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
dialog.getWindow().setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
dialog.findViewById(R.id.img_close_popup).setOnClickListener(v1 -> {
    dialog.cancel();
});
dialog.show();


<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/dialog_layout"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <com.github.chrisbanes.photoview.PhotoView
        android:id="@+id/content_image"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="fitCenter"
        android:src="@drawable/test"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ImageView
        android:id="@+id/img_close_popup"
        android:layout_width="75dp"
        android:layout_height="75dp"
        android:padding="24dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        android:src="@drawable/ic_close" />

</androidx.constraintlayout.widget.ConstraintLayout>


5ee467757aaac041189609.jpeg

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question