llr7245
llr7245

Reputation: 33

Android Dialog keeps fidgeting - won't remain one size

I have a pop-up dialog that is prompted by a button. I recently added a few more categories to be displayed on the screen, and now the dialog is behaving strangely. After I click the prompt, the dialog pops up, but it doesn't remain still; instead, it repeatedly gets thinner then wider, and just moving quickly back and forth. Has anyone else encountered this? Here is the XML code for the pop-up:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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:layout_width="wrap_content"
android:layout_height="wrap_content">


<TextView
    android:id="@+id/productName"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    android:text="TEST"
    android:gravity="center"
    android:textSize="25sp"
    android:layout_marginTop="16dp"
    app:layout_constraintTop_toBottomOf="@+id/productImage" />

<TextView
    android:id="@+id/category"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Category"
    android:textSize="20sp"
    android:gravity="center"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    android:layout_marginTop="16dp"
    app:layout_constraintTop_toBottomOf="@+id/productName" />

<TextView
    android:id="@+id/size"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="left"
    android:text="size"
    app:layout_constraintRight_toLeftOf="@+id/powerType"
    android:layout_marginRight="8dp"
    app:layout_constraintTop_toTopOf="@+id/powerType"
    android:layout_marginTop="0dp" />

<TextView
    android:id="@+id/horsepower"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="horsepower"
    android:gravity="left"
    app:layout_constraintLeft_toRightOf="@+id/voltage"
    android:layout_marginLeft="8dp"
    app:layout_constraintTop_toTopOf="@+id/voltage"
    android:layout_marginTop="0dp" />

<TextView
    android:id="@+id/powerType"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="power type"
    android:gravity="left"
    android:layout_marginTop="16dp"
    app:layout_constraintTop_toBottomOf="@+id/category"
    android:layout_marginLeft="0dp"
    app:layout_constraintLeft_toLeftOf="@+id/category"
    android:layout_marginRight="0dp"
    app:layout_constraintRight_toRightOf="@+id/category"
    app:layout_constraintHorizontal_bias="0.473" />

<TextView
    android:id="@+id/expProof"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="exp Proof"
    android:gravity="left"
    app:layout_constraintLeft_toRightOf="@+id/powerType"
    android:layout_marginLeft="8dp"
    app:layout_constraintTop_toTopOf="@+id/powerType"
    android:layout_marginTop="0dp" />

<TextView
    android:id="@+id/psi"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="PSI"
    android:gravity="left"
    app:layout_constraintRight_toLeftOf="@+id/gpm"
    android:layout_marginRight="8dp"
    android:layout_marginTop="0dp"
    app:layout_constraintTop_toTopOf="@+id/gpm" />

<TextView
    android:id="@+id/gpm"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="GPM"
    android:gravity="left"
    android:layout_marginTop="24dp"
    app:layout_constraintTop_toBottomOf="@+id/voltage"
    android:layout_marginLeft="0dp"
    app:layout_constraintLeft_toLeftOf="@+id/voltage"
    android:layout_marginRight="0dp"
    app:layout_constraintRight_toRightOf="@+id/voltage"
    app:layout_constraintHorizontal_bias="0.0" />

<TextView
    android:id="@+id/rpm"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="RPM"
    android:gravity="left"
    app:layout_constraintLeft_toRightOf="@+id/gpm"
    android:layout_marginLeft="8dp"
    app:layout_constraintTop_toTopOf="@+id/gpm"
    android:layout_marginTop="0dp" />

<TextView
    android:id="@+id/price"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Price"
    android:textSize="20sp"
    android:gravity="center"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    android:layout_marginTop="24dp"
    app:layout_constraintTop_toBottomOf="@+id/gpm" />

<Button
    android:id="@+id/closeDetails"
    android:layout_width="@dimen/popUpDetailSections"
    android:layout_height="41dp"
    android:text="@string/okayButton"
    android:gravity="left"
    android:textSize="15sp"
    android:backgroundTint="@color/colorPrimary"
    android:textColor="@color/white"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    android:layout_marginTop="32dp"
    app:layout_constraintTop_toBottomOf="@+id/price" />

<ImageView
    android:id="@+id/productImage"
    android:layout_width="200dp"
    android:layout_height="124dp"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:srcCompat="@drawable/exp_proof_pump_skid"
    app:layout_constraintTop_toTopOf="parent"
    android:layout_marginTop="16dp" />

<TextView
    android:id="@+id/voltage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="voltage"
    android:gravity="left"
    android:layout_marginTop="16dp"
    app:layout_constraintTop_toBottomOf="@+id/powerType"
    android:layout_marginLeft="0dp"
    app:layout_constraintLeft_toLeftOf="@+id/powerType"
    android:layout_marginRight="0dp"
    app:layout_constraintRight_toRightOf="@+id/powerType"
    app:layout_constraintHorizontal_bias="0.0" />

<TextView
    android:id="@+id/phase"
    android:layout_width="wrap_content"
    android:layout_height="16dp"
    android:text="phase"
    android:gravity="left"
    app:layout_constraintRight_toLeftOf="@+id/voltage"
    android:layout_marginRight="8dp"
    app:layout_constraintTop_toTopOf="@+id/voltage"
    android:layout_marginTop="0dp" />
</android.support.constraint.ConstraintLayout>

https://i.sstatic.net/3scVl.png <- this is a screenshot of the dialog. So the boundaries keep expanding and compressing, and the text keeps moving too.

Upvotes: 2

Views: 37

Answers (1)

AskNilesh
AskNilesh

Reputation: 69689

try this

Window window = customDialog.getWindow();
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT,WindowManager.LayoutParams.WRAP_CONTENT);

Upvotes: 1

Related Questions