Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 复选框和TextInputLayout在线性布局中未正确对齐_Android_Android Layout - Fatal编程技术网

Android 复选框和TextInputLayout在线性布局中未正确对齐

Android 复选框和TextInputLayout在线性布局中未正确对齐,android,android-layout,Android,Android Layout,我在一个线性布局中有两个复选框和一个TextInputLayout。但他们没有得到适当的渲染。复选框正在向下移动。我什么都试过了,但他们没有对齐 我的代码如下: <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical" androi

我在一个线性布局中有两个复选框和一个TextInputLayout。但他们没有得到适当的渲染。复选框正在向下移动。我什么都试过了,但他们没有对齐

我的代码如下:

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:orientation="horizontal">

        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/layoutSysCardNo"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginEnd="8dp"
            android:layout_weight="2"
            app:boxBackgroundColor="@color/white_50"
            app:counterMaxLength="10">

            <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/sysCardNo"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/field_enter_sys_job_no"
                android:inputType="number" />
        </com.google.android.material.textfield.TextInputLayout>

        <com.google.android.material.checkbox.MaterialCheckBox
            android:id="@+id/hmsiWarranty"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginEnd="8dp"
            android:layout_weight="1"
            android:text="@string/vehicle_delievered" />

        <com.google.android.material.checkbox.MaterialCheckBox
            android:id="@+id/extWarranty"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginEnd="8dp"
            android:layout_weight="1"
            android:text="@string/vehicle_delievered" />

    </LinearLayout>

输出如下所示


只需在您的
线性布局中使用
android:gravity=“center”
即可解决您的问题

试试这个

 <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:gravity="center"
        android:orientation="horizontal">

        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/layoutSysCardNo"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginEnd="8dp"
            android:layout_weight="2"
            app:boxBackgroundColor="@color/white_50"
            app:counterMaxLength="10">

            <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/sysCardNo"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/field_enter_sys_job_no"
                android:inputType="number" />
        </com.google.android.material.textfield.TextInputLayout>

        <com.google.android.material.checkbox.MaterialCheckBox
            android:id="@+id/hmsiWarranty"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginEnd="8dp"
            android:layout_weight="1"
            android:text="@string/vehicle_delievered" />

        <com.google.android.material.checkbox.MaterialCheckBox
            android:id="@+id/extWarranty"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginEnd="8dp"
            android:layout_weight="1"
            android:text="@string/vehicle_delievered" />

    </LinearLayout>