android 登录密码显示错误,EditText错误图标并显示密码错误放置

我有一个EditText作为这样的密码输入

android:layout_width="match_parent"

android:layout_height="wrap_content">

android:id="@+id/password"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="@string/prompt_password"

android:imeActionId="@+id/login"

android:imeActionLabel="@string/action_sign_in_short"

android:imeOptions="actionUnspecified"

android:inputType="textPassword"

android:maxLines="1"

android:singleLine="true" />

它可以正常工作,但是当出现错误时,错误图标会显示两次,并且位于显示密码图标的顶部。

错误图标放错了位置

我的验证代码显示错误:

if (success) {

finish();

startMainActivity();

} else {

mPasswordView.setError(getString(R.string.error_incorrect_password));

mPasswordView.requestFocus();

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我可以给你一些关于设计美观登录界面的建议。首先,我们需要考虑颜色搭配和布局。以下是一个参考设计: 1. 背景色:使用深色背景,例如黑色或深蓝色,可以给用户带来专业且高端的感觉。 2. 布局:将用户名和密码输入框放置在页面中心,以便用户容易找到它们。登录按钮应该在输入框的下方,以便用户轻松地点击它。 3. 字体:使用清晰易读的字体,例如Roboto或Open Sans。 4. 颜色搭配:在深色背景上使用鲜艳的颜色来突出输入框和按钮。例如,使用亮绿色或亮红色来突出登录按钮。 5. 图标:可以在用户名和密码输入框旁边放置相应的图标,例如人物图标和锁图标,来表示用户名和密码的输入框。 以下是一个简单的代码示例,可以在Android Studio中使用: ``` <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#000000"> <ImageView android:id="@+id/logo" android:layout_width="200dp" android:layout_height="80dp" android:layout_centerHorizontal="true" android:layout_marginTop="100dp" android:src="@drawable/logo" /> <EditText android:id="@+id/username" android:layout_width="250dp" android:layout_height="wrap_content" android:layout_below="@id/logo" android:layout_centerHorizontal="true" android:layout_marginTop="30dp" android:background="#FFFFFF" android:hint="用户名" android:padding="10dp" /> <EditText android:id="@+id/password" android:layout_width="250dp" android:layout_height="wrap_content" android:layout_below="@id/username" android:layout_centerHorizontal="true" android:layout_marginTop="20dp" android:background="#FFFFFF" android:hint="密码" android:inputType="textPassword" android:padding="10dp" /> <Button android:id="@+id/login" android:layout_width="250dp" android:layout_height="wrap_content" android:layout_below="@id/password" android:layout_centerHorizontal="true" android:layout_marginTop="30dp" android:background="#66FF00" android:text="登录" android:textColor="#FFFFFF" /> </RelativeLayout> ``` 希望这能对你有所帮助,如果你需要更多帮助,请告诉我。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值