ConstraintLayout无法在横向模式下工作,请提供帮助。
XML
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="25dp">
<android.support.constraint.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.375" />
<android.support.constraint.Guideline
android:id="@+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.5" />
<android.support.constraint.Guideline
android:id="@+id/guideline3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.625" />
<android.support.constraint.Guideline
android:id="@+id/guideline4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.750" />
<android.support.constraint.Guideline
android:id="@+id/guideline5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.875" />
<android.support.constraint.Guideline
android:id="@+id/guideline6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />
<ImageView
android:id="@+id/imgHeader"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/white"
app:layout_constraintBottom_toTopOf="@+id/guideline"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@drawable/paperranger" />
<Button
android:id="@+id/btnDonate"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/bg_button_payment_square"
android:text="@string/donate"
android:textColor="@color/white"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline5"
app:layout_constraintVertical_bias="1.0" />
<TextView
android:id="@+id/tvCardNumber"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/dp8"
android:layout_marginStart="@dimen/dp8"
android:layout_marginTop="@dimen/dp8"
android:text="@string/card_number"
app:layout_constraintBottom_toTopOf="@+id/edtCardNumber"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/guideline" />
<com.omise.mobile.omisetumboon.ui.view.CreditCardEditText
android:id="@+id/edtCardNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp8"
android:layout_marginEnd="@dimen/dp8"
android:layout_marginStart="@dimen/dp8"
android:ems="10"
app:layout_constraintBottom_toTopOf="@+id/guideline2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvCardNumber" />
<EditText
android:id="@+id/edtCardName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp8"
android:layout_marginEnd="@dimen/dp8"
android:layout_marginStart="@dimen/dp8"
android:ems="10"
android:inputType="text"
app:layout_constraintBottom_toTopOf="@+id/guideline3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2" />
<TextView
android:id="@+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/dp8"
android:layout_marginStart="@dimen/dp8"
android:layout_marginTop="@dimen/dp8"
android:text="@string/name_on_card"
app:layout_constraintBottom_toTopOf="@+id/edtCardName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/guideline2"
tools:layout_editor_absoluteY="366dp" />
<TextView
android:id="@+id/tvExpairyDate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/dp8"
android:layout_marginStart="@dimen/dp8"
android:layout_marginTop="@dimen/dp8"
android:text="@string/expairy_date"
app:layout_constraintBottom_toTopOf="@+id/spnYear"
app:layout_constraintEnd_toStartOf="@+id/guideline6"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/guideline3" />
<TextView
android:id="@+id/tvCvv"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/dp8"
android:layout_marginStart="@dimen/dp8"
android:layout_marginTop="@dimen/dp8"
android:text="@string/cvv"
app:layout_constraintBottom_toTopOf="@+id/edtSecurityCode"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="@+id/guideline6"
app:layout_constraintTop_toBottomOf="@+id/guideline3" />
<EditText
android:id="@+id/edtSecurityCode"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp8"
android:layout_marginEnd="@dimen/dp8"
android:layout_marginStart="@dimen/dp8"
android:ems="10"
android:inputType="numberPassword"
android:maxLength="3"
app:layout_constraintBottom_toTopOf="@+id/guideline4"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="@+id/guideline6"
app:layout_constraintTop_toBottomOf="@+id/tvCvv" />
<TextView
android:id="@+id/textView5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/dp8"
android:layout_marginStart="@dimen/dp8"
android:layout_marginTop="@dimen/dp8"
android:text="@string/amount"
app:layout_constraintBottom_toTopOf="@+id/edtAmount"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/guideline4" />
<EditText
android:id="@+id/edtAmount"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp8"
android:layout_marginEnd="@dimen/dp8"
android:layout_marginStart="@dimen/dp8"
android:ems="10"
android:inputType="numberDecimal"
app:layout_constraintBottom_toTopOf="@+id/guideline5"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView5"
tools:layout_editor_absoluteY="457dp" />
<Spinner
android:id="@+id/spnMonth"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp8"
android:layout_marginLeft="@dimen/dp8"
android:layout_marginStart="@dimen/dp8"
app:layout_constraintBottom_toTopOf="@+id/guideline4"
app:layout_constraintEnd_toStartOf="@+id/spnYear"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvExpairyDate" />
<Spinner
android:id="@+id/spnYear"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp8"
android:layout_marginEnd="@dimen/dp8"
android:layout_marginRight="@dimen/dp8"
app:layout_constraintBottom_toTopOf="@+id/guideline4"
app:layout_constraintEnd_toStartOf="@+id/guideline6"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/spnMonth"
app:layout_constraintTop_toBottomOf="@+id/tvExpairyDate" />
</android.support.constraint.ConstraintLayout>
风景
波泰特
答案 0 :(得分:0)
工具:layout_editor_absoluteY = “25dp”
将高度固定为绝对值25