How to make two Theme.MaterialComponents.Dialog with same size?

79 views Asked by At

I have an AppCompatActivity which starts another AppCompatActivity as a dialog by setting theme="@style/Theme.MaterialComponents.Dialog" in manifest.xml. This dialog is displayed nicely with margins on all sides.

The first dialog starts a second dialog with the same settings. But this dialog has margins on all sides as well but seems to have the first dialog as reference. So the second dialog is smaller then the first one but I want it to be the same size. Is this possible?

Schematic overview of dialogs

Manifest.xml:

<activity android:name=".activity.Dialog1"
    android:label="Custom"
    android:theme="@style/Theme.MaterialComponents.Dialog"
    android:windowSoftInputMode="adjustResize"
    />
<activity android:name=".activity.Dialog2"
    android:label="Custom"
    android:theme="@style/Theme.MaterialComponents.Dialog"
    android:windowSoftInputMode="adjustResize"
    />

Dialog1.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent" android:layout_gravity="center"
    android:id="@+id/dialog1_layout">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/add_poi_text"
        android:textSize="30sp"
        android:text="@string/add_poi_text"
        android:textColor="@color/colorPrimary"
        android:layout_marginStart="20dp"
        android:layout_marginTop="20dp"
        />
</RelativeLayout>

Dialog2.xml

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:id="@+id/poi_specific_layout">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:visibility="gone"
        android:id="@+id/default_fields_placeholder">
    </RelativeLayout>
</LinearLayout>
0

There are 0 answers