当我从非活动状态的EditText中删除一个值时,它看起来像这样:
答案 0 :(得分:1)
我认为这是TextInputEditText
和TextInputLayout
的默认行为,可以直接设置属性,但是您可以通过一些设置来解决此问题:
您可以向其中添加FocusChange
事件,当它不清晰时,为其设置一个" "
(空值):
TextInputEditText textInputEditText = FindViewById<TextInputEditText>(Resource.Id.editText);
textInputEditText.FocusChange += delegate
{
if (!textInputEditText.IsFocused)
{
if (string.IsNullOrEmpty( textInputEditText.Text))
{
textInputEditText.Text = " ";
}
}
else
{
if (textInputEditText.Text == " ")
{
textInputEditText.Text = "";
}
}
};
答案 1 :(得分:0)
根据文档,您应该按如下所示将编辑文本包装在TextInputLayout中:
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/form_username">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
还要确保在应用的gradle构建文件中具有材质设计库。希望这会有所帮助:)