如何在同一行中使用两个TextInputLayout(Material Design)
,即水平使用,以便它们必须均匀地获取线性布局中的所有水平空间。我尝试过线性布局
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5">
<EditText
android:id="@+id/firstname"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:hint="@string/fhint"
android:inputType="textPersonName"
android:maxLength="20"
android:maxLines="1"
android:elevation="6dp"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5">
<EditText
android:id="@+id/lastname"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:hint="@string/lhint"
android:inputType="textPersonName"
android:elevation="6dp"
android:maxLines="1"
android:maxLength="15"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
答案 0 :(得分:1)
只应在TextInputLayout中设置权重,将其从EditTexts中删除
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5">
<EditText
android:id="@+id/firstname"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="@string/fhint"
android:inputType="textPersonName"
android:maxLength="20"
android:maxLines="1"
android:elevation="6dp"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5">
<EditText
android:id="@+id/lastname"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="@string/lhint"
android:inputType="textPersonName"
android:elevation="6dp"
android:maxLines="1"
android:maxLength="15"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>