Диалог с полноэкранным макетом - PullRequest
0 голосов
/ 22 октября 2019

Макет в полноэкранном диалоге не отображается должным образом.

Это мой код диалога:

val mDialogView = LayoutInflater.from (this) .inflate (R.layout.alertdialog_info, null)

    val mBuilder = AlertDialog.Builder(this, R.style.FullScreenDialog)
            .setView(mDialogView)

    val mAlertDialog = mBuilder.show()

    mDialogView.titleTv.text = getString(R.string.title)
    mDialogView.descriptionTv.text = getString(R.string.description)

    mAlertDialog.show()

в style.xml это мой FullScreenDialog:

<style name="FullScreenDialog" parent="android:Theme.Dialog">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">match_parent</item>
    <item name="android:windowBackground">@color/md_white_1000</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowIsFloating">false</item>
</style>

А это мой макет:

 <?xml version="1.0" encoding="utf-8"?>
    <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        xmlns:tools="http://schemas.android.com/tools"
        android:paddingTop="16dp"
        android:gravity="bottom"
        android:layout_marginStart="16dp"
        android:layout_marginEnd="16dp"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:background="@color/md_white_1000">

                <ImageView
                    android:id="@+id/iconIv"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="50dp"
                    android:src="@drawable/ic_success"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintBottom_toTopOf="@id/titleTv" />

                <TextView
                    android:id="@+id/titleTv"
                    style="@style/FontLocalizedBold"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    tools:text="@string/payment_success"
                    android:textColor="@color/colorTextPrimary"
                    android:textSize="24sp"
                    android:layout_marginStart="24dp"
                    android:gravity="center"
                    android:layout_marginEnd="24dp"
                    android:maxLines="2"
                    android:layout_marginTop="16dp"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    app:layout_constraintBottom_toBottomOf="parent" />


                <TextView
                    android:id="@+id/descriptionTv"
                    style="@style/FontLocalizedMedium"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="24dp"
                    android:layout_marginTop="48dp"
                    android:layout_marginEnd="24dp"
                    android:gravity="center"
                    tools:text="@string/payment_success_description"
                    android:textSize="17sp"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@id/titleTv" />

                <TextView
                    android:id="@+id/okTv"
                    style="@style/ButtonTextView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="16dp"
                    android:layout_marginEnd="16dp"
                    android:paddingBottom="16dp"
                    android:background="@drawable/save_button_active"
                    android:text="@string/done"
                    app:layout_constraintBottom_toBottomOf="parent" />

    </androidx.constraintlayout.widget.ConstraintLayout>

Я пробовал с LinearLayoutвместо ConstraintLayout, но тот же результат.

Я приложил картинки с тем, как мой xml-файл выглядит и как он отображается на эмуляторе, игнорируйте, пожалуйста, разные строковые значения.

эмулятор: emulator

xml: xml

Есть идеи, что может вызвать разницу в рендеринге?

1 Ответ

1 голос
/ 23 октября 2019

Похоже, вам нужно обновить стиль предварительного просмотра в программе просмотра XML. Я выделил раскрывающийся список для использования в текущей версии AndroidStudio.

Click dropdown box to change preview style

...