Je veux creat un dialogFragment comme ceci:GuideLine ne fonctionnent pas dans DialogFragment
En fait, je suis sur mon téléphone:
button1 est couvert par Bouton2 . Il semble que le guide ne fonctionne pas. Si textView est assez long, cela fonctionne bien. Mais si textView est court, le problème arrivera. Comment puis-je résoudre le problème?
ma boîte de dialogue XML est:
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="32dp">
<TextView
android:id="@+id/dialog_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dialog Message"
android:textAppearance="?android:attr/textAppearanceMedium"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.support.constraint.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />
<Button
android:id="@+id/dialog_button_positive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:layout_marginRight="32dp"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="Positive"
android:textAppearance="?android:textAppearanceButton"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/guideline"
app:layout_constraintTop_toBottomOf="@id/dialog_message" />
<Button
android:id="@+id/dialog_button_negative"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:layout_marginRight="32dp"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="Negative"
android:textAppearance="?android:textAppearanceButton"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@id/guideline"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/dialog_message" />
</android.support.constraint.ConstraintLayout>
Je l'ai fait en tant que votre réponse, mais le deuxième bouton affiché incomplete.I résoudre le problème par appel setLayout. Donc j'ajoute 'getDialog(). GetWindow(). SetLayout()' dans la méthode 'onStart()' –