android - 当 EditText 处于非活动状态时如何设置提示位置
问题描述
当我在我的 EditText 中调整了一些不活动的值时,它看起来如下图所示:
当我从处于非活动状态的 EditText 中删除一个值时,它看起来像这样:
是否可以设置 TextInputLayer 或 TextInputEditText 的某些属性以在非活动状态下获得行为,如下所示:
解决方案
我认为这是TextInputEditText
with的默认行为TextInputLayout
,有属性可以直接设置它,但是您可以通过进行一些设置来做到这一点,作为一种解决方法:
你可以FocusChange
给它添加事件,当它不在焦点时," "
给它设置一个(空值):</p>
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 = "";
}
}
};
推荐阅读
- javascript - 为什么我的侧边导航菜单不会被这个 jquery 幻灯片效果隐藏?
- python - 如何加密字典数据?
- java - JMS 队列是 Java Util 队列的实现吗?使用 Java Util Queue 实现的 Java 包中有哪些类?
- ubuntu - Ubuntu 14.04.5 LTS:监视警报 -- 连接失败 sshd
- javascript - JavaScript 在添加时崩溃
- excel - 为不同的 Excel 工作簿执行相同的代码时发生运行时错误 1004
- postgresql - postgres 中排除约束的要点
- sql-server - 在 SQL Server 的一个过程中使用 UNION ALL 从不同数据库中的两个不同函数获取记录
- odoo - 是否存在在odoo中不同版本之间迁移数据库的方法
- aws-lambda - 长时间运行的 lambda 等待 Airflow 中的响应超时