0
工作,我想創造這樣的dialogFragment:準則不DialogFragment
其實我得到這個我的手機上:
Button1是BUTTON2覆蓋。它看起來像guideline不起作用。 如果textView足夠長,它運作良好。但是如果textView很短,問題就會發生。我該如何解決這個問題。
我的對話框XML是:
<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>
我照你的答案,但第二個按鈕顯示incomplete.I通過調用setLayout的解決這個問題。所以我在'onStart()'方法中添加'getDialog()。getWindow()。setLayout()'' –