是否可以将这些浮动标签(电子邮件/密码)放在包装盒内.基本上减少了提示和实际输入之间的空间.
我尝试填充顶部/底部.用于editText的边距顶部/底部.但他们都没有给出我想要的结果.
<android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:id="@+id/emailWrapper" app:hintTextAppearance="@style/floatingLabel"> <EditText android:layout_width="match_parent" android:layout_height="54dp" android:paddingLeft="17dp" android:paddingRight="17dp" android:id="@+id/txtEmail" android:singleLine="true" android:inputType="textEmailAddress" android:hint="@string/emailPlaceholder" android:background="@drawable/btn_empty_stroke" /> </android.support.design.widget.TextInputLayout> <android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" app:hintTextAppearance="@style/floatingLabel" android:id="@+id/passwordWrapper" android:layout_below="@+id/emailWrapper"> <EditText android:layout_width="match_parent" android:layout_height="54dp" android:paddingLeft="17dp" android:paddingRight="17dp" android:singleLine="true" android:inputType="textPassword" android:id="@+id/txtPassword" android:paddingTop="0dp" android:text="HELLO" android:hint="@string/passwordPlaceholder" android:background="@drawable/btn_empty_stroke" /> </android.support.design.widget.TextInputLayout>
解决方法
感谢@Frank N.Stein的评论和减少高度的想法.它成功了.
回答我自己的问题.正如其他人可能会提出这个问题.
所以基本上我必须给TextInputLayout准确的高度并保持EditText高度相同.还要将paddingTop赋予TextInputLayout并将clipToPadding设为false.所以最终的文本框xml就是这样出来的.
<android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_marginTop="20dp" android:layout_height="54dp" android:gravity="bottom" android:paddingTop="4dp" android:clipToPadding="false" // above 3 lines are important android:id="@+id/emailWrapper" app:hintTextAppearance="@style/floatingLabel"> <EditText android:layout_width="match_parent" android:layout_height="54dp" android:paddingLeft="17dp" android:paddingRight="17dp" android:id="@+id/txtEmail" android:singleLine="true" android:inputType="textEmailAddress" android:hint="@string/emailPlaceholder" android:text="a@a.com" android:background="@drawable/btn_empty_stroke" /> </android.support.design.widget.TextInputLayout>