Android 中的布局响应问题

Layout responsiveness issue in Android

我的 xml 设计以线性布局为根,并在内部使用了此约束布局。 在使用布局验证器时,我在 响应能力 中遇到问题 (this)。请建议我。

LinearLayout 和 ConstraintLayout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    

全名 EdittextView

     <EditText
        android:id="@+id/et_full_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:layout_marginStart="@dimen/activity_start_margin"
        android:layout_marginEnd="@dimen/activity_end_margin"
        android:background="@drawable/rectangle_pedittext"
        android:drawableStart="@drawable/ic_full_name"
        android:drawablePadding="@dimen/activity_start_margin"
        android:fontFamily="@font/poppins_regular"
        android:gravity="center_vertical"
        android:hint="@string/prompt_full_name"
        android:inputType="textPersonName"
        android:paddingLeft="@dimen/activity_start_padding"
        android:selectAllOnFocus="true"
        android:textColorHint="#C0C0C0"
        android:textSize="@dimen/_11ssp" />
    

给 EdittextView 发邮件

           <EditText
            android:id="@+id/et_email"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:layout_marginStart="@dimen/activity_start_margin"
            android:layout_marginEnd="@dimen/activity_end_margin"
            android:background="@drawable/rectangle_pedittext"
            android:drawableStart="@drawable/ic_icon_user"
            android:drawablePadding="@dimen/activity_start_margin"
            android:fontFamily="@font/poppins_regular"
            android:gravity="center_vertical"
            android:hint="@string/prompt_email"
            android:inputType="textEmailAddress"
            android:paddingLeft="@dimen/activity_start_padding"
            android:selectAllOnFocus="true"
            android:textColorHint="#C0C0C0"
            android:textSize="@dimen/_11ssp" />
        

 **Spinner for Country Option**

          <Spinner
            android:id="@+id/et_country_name"
            style="@style/SpinnerTheme"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:layout_marginStart="@dimen/activity_start_margin"
            android:layout_marginEnd="@dimen/activity_end_margin"
            android:paddingLeft="@dimen/_50sdp" />
    

Phone 数 EditTextView

    <EditText
        android:id="@+id/et_phone_details"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="30dp"
        android:layout_marginStart="@dimen/activity_start_margin"
        android:layout_marginEnd="@dimen/activity_end_margin"
        android:background="@drawable/rectangle_pedittext"
        android:drawableStart="@drawable/ic_phone"
        android:drawablePadding="@dimen/activity_start_margin"
        android:fontFamily="@font/poppins_regular"
        android:gravity="center_vertical"
        android:hint="@string/prompt_phone"
        android:inputType="phone"
        android:paddingLeft="@dimen/activity_start_padding"
        android:selectAllOnFocus="true"
        android:textColorHint="#C0C0C0"
        android:textSize="@dimen/_11ssp" />
    

弹出生日日历提醒对话框

       <EditText
            android:id="@+id/et_date_of_birth"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:layout_marginStart="@dimen/activity_start_margin"
            android:layout_marginEnd="@dimen/activity_end_margin"
            android:background="@drawable/rectangle_pedittext"
            android:drawableStart="@drawable/ic_dob"
            android:drawablePadding="@dimen/activity_start_margin"
            android:fontFamily="@font/poppins_regular"
            android:gravity="center_vertical"
            android:hint="@string/prompt_dob"
            android:paddingLeft="@dimen/activity_start_padding"
            android:selectAllOnFocus="true"
            android:textColorHint="#C0C0C0"
            android:textSize="@dimen/_11ssp" />
    

EditTextView for password

<EditText
    android:id="@+id/et_password"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="30dp"
    android:layout_marginStart="@dimen/activity_start_margin"
    android:layout_marginEnd="@dimen/activity_end_margin"
    android:background="@drawable/rectangle_pedittext"
    android:drawableStart="@drawable/ic_icon_password"
    android:drawablePadding="@dimen/activity_start_margin"
    android:fontFamily="@font/poppins_regular"
    android:gravity="center_vertical"
    android:hint="@string/prompt_password"
    android:inputType="textPassword"
    android:paddingLeft="@dimen/activity_start_padding"
    android:selectAllOnFocus="true"
    android:textColorHint="#C0C0C0"
    android:textSize="14sp" />

确认密码的EditTextView

  <EditText
    android:id="@+id/et_confirm_password"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="30dp"
    android:layout_marginStart="@dimen/activity_start_margin"
    android:layout_marginEnd="@dimen/activity_end_margin"
    android:background="@drawable/rectangle_pedittext"
    android:drawableStart="@drawable/ic_icon_password"
    android:drawablePadding="@dimen/activity_start_margin"
    android:fontFamily="@font/poppins_regular"
    android:gravity="center_vertical"
    android:hint="@string/prompt_confirm_password"
    android:inputType="textPassword"
    android:paddingLeft="@dimen/activity_start_padding"
    android:selectAllOnFocus="true"
    android:textColorHint="#C0C0C0"
    android:textSize="14sp" />
        

约束布局设计

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    

rombus 图片 页脚中存在半个 rombus 图片(即 2 张图片)

<ImageView
    android:id="@+id/imageView3"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:paddingEnd="@dimen/_40sdp"
    android:src="@drawable/mask_group"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.0" />

注册按钮

        <Button
            android:id="@+id/btn_signUp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/sign_btn"
            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="parent"
            app:layout_constraintVertical_bias="0.835" />
    </androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>

在线性布局中尝试 weightSum,您可以在其子布局中设置 layout_weight 的值。

例如:如果您将 weightSum 的值设置为等于 10,那么您可以将它的子级除以 textview 和 imageview 等分别等于 6 和 4 等于 10。

如需更多帮助,请阅读此 article