'Squared non transparent background on custom input dialog

I have created a custom input dialog for my application, and in terms of funcionality it works, but every time it has a sort of square background which distones from the actual dialog content. I tried to set a background color to tranparent e to a custom background to remove it, but it did not work. I would like help to know how can I make it so only the actual dialog appears without this background. I'm also using Material components to create the dialog, with MaterialCardView for the base, MaterialTextView and MaterialButton.

This is my dialog xml

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/material_name_input_field"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:clickable="true"
    android:focusable="true"
    android:theme="@style/Theme.MaterialComponents.DayNight.Dialog.Alert"
    app:cardCornerRadius="16dp"
    app:cardElevation="1dp"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">
    <!--    -->

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/input_field"
        android:layout_width="wrap_content"
        android:layout_height="match_parent">

        <com.google.android.material.textview.MaterialTextView
            android:id="@+id/input_name_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:text="@string/input_serie_name"
            android:textSize="16pt"
            app:layout_constraintEnd_toStartOf="@+id/name_input_field"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <com.google.android.material.textfield.MaterialAutoCompleteTextView
            android:id="@+id/name_input_field"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="16dp"
            android:text="@string/empty_text_input_field"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toEndOf="@+id/input_name_title"
            app:layout_constraintTop_toTopOf="parent" />

        <com.google.android.material.button.MaterialButton
            android:id="@+id/negative"
            style="@style/Widget.Material3.Button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:text="@string/cancel"
            android:textSize="8pt"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/name_input_field" />

        <com.google.android.material.button.MaterialButton
            android:id="@+id/positive"
            style="@style/Widget.Material3.Button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="16dp"
            android:text="@string/done"
            android:textSize="8pt"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/name_input_field" />


    </androidx.constraintlayout.widget.ConstraintLayout>

</com.google.android.material.card.MaterialCardView>

Creating dialog here:

var inputDialog: InputDialog = InputDialog(parent)
inputDialog
   .setCallbackFunction {
        doSetSeriesName(series, it.toString(), onCardCreatedCallback)
                inputDialog.dismiss()
            }
    .setTitle("Series Name:")
    .show()

Dialog code

class InputDialog(
    private var activity: Activity) : Dialog(activity), View.OnClickListener {
    companion object {
        private var TAG = "InputDialog"
    }

    private lateinit var textView: EditText
    private lateinit var titleTextView: TextView
    private lateinit var positive: MaterialButton
    private lateinit var negative: MaterialButton
    private lateinit var callbackFunction: (value: Any) -> Unit

    fun setCallbackFunction(callbackFunction: (value: Any) -> Unit): InputDialog {
        this.callbackFunction = callbackFunction
        return this
    }

    fun setTitle(title: String): InputDialog {
        titleTextView = findViewById(R.id.input_name_title)
        titleTextView.text = title
        return this
    }

    override fun onClick(view: View?) {
        when (view?.id)  {
            R.id.positive -> {
                callbackFunction(textView.text)
            }
            R.id.negative -> {
                dismiss()
            }
            R.id.name_input_field -> {
                SCLog.d(TAG, "Editing Name")
                textView.text.clear()
            }
            else -> {
                SCLog.d(TAG, "onClick: Unknown view.id")
            }
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        SCLog.d(TAG, "onCreate: creating dialog")
        super.onCreate(savedInstanceState)
        requestWindowFeature(Window.FEATURE_NO_TITLE)
        setContentView(R.layout.input_dialog)
        textView = findViewById(R.id.name_input_field)
        textView.text.clear()
        textView.setHint(R.string.series_name_title)
        positive = findViewById(R.id.positive)
        negative = findViewById(R.id.negative)

        positive.setOnClickListener(this)
        negative.setOnClickListener(this)
    }
}

And this is a image of how it currently is: enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source