发生错误时 TextInputLayout 更改宽度

TextInputLayout change width when error occurred

我有 LinearLayout 和两个嵌套的 TextInputLayout

没有报错就OK了。 但是当发生错误时,TextInputLayout 的大小会发生变化。 请告诉我,我做错了什么。

<LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginLeft="16dp"
      android:layout_marginRight="16dp"
      android:layout_marginTop="40dp"
      android:baselineAligned="false"
      android:orientation="horizontal">

       <android.support.design.widget.TextInputLayout
        android:id="@+id/textInputPower"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="5dp"
        android:layout_weight="1"
        android:orientation="horizontal">

         <EditText
          android:id="@+id/editText3"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:digits=".0123456789"
          android:hint="Мощность (W)"
          android:inputType="numberDecimal"
          android:maxLength="10"
          android:textColor="@color/text_color_nav"
          android:textSize="14sp" />
         </android.support.design.widget.TextInputLayout>

          <android.support.design.widget.TextInputLayout
           android:id="@+id/textInputAmperage"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_marginLeft="5dp"
           android:layout_weight="1">

            <EditText
             android:id="@+id/editText"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:digits=".0123456789"
             android:hint="Ток (А)"
             android:inputType="numberDecimal"
             android:maxLength="10"
             android:textColor="@color/text_color_nav"
             android:textSize="14sp" />
            </android.support.design.widget.TextInputLayout>
    </LinearLayout>

线性布局使用权重和。

    <LinearLayout android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
    android:layout_marginTop="40dp"
    android:baselineAligned="false"
    android:weightSum="2"
    android:orientation="horizontal"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <android.support.design.widget.TextInputLayout
        android:id="@+id/textInputPower"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginRight="5dp"
        android:layout_weight="1"
        android:orientation="horizontal">

        <EditText
            android:id="@+id/editText3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:digits=".0123456789"
            android:hint="Мощность (W)"
            android:inputType="numberDecimal"
            android:maxLength="10"
            android:textColor="@color/text_color_nav"
            android:textSize="14sp" />
    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:id="@+id/textInputAmperage"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_weight="1">

        <EditText
            android:id="@+id/editText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:digits=".0123456789"
            android:hint="Ток (А)"
            android:inputType="numberDecimal"
            android:maxLength="10"
            android:textColor="@color/text_color_nav"
            android:textSize="14sp" />
    </android.support.design.widget.TextInputLayout>
</LinearLayout>