Edittext 回车键
<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" android:background="@mipmap/bg_login"> <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/layout_1" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" android:layout_width="283dp" android:layout_height="247dp" android:background="@mipmap/bg1_login" app:layout_constraintVertical_bias="0.45"> <LinearLayout android:id="@+id/layout_name" app:layout_constraintTop_toTopOf="parent" app:layout_constraintLeft_toLeftOf="parent" android:layout_marginLeft="26dp" android:layout_marginTop="80dp" android:layout_width="228dp" android:layout_height="wrap_content" android:gravity="center_vertical" android:background="@drawable/login_background_name"> <ImageView android:layout_width="17dp" android:layout_height="17dp" android:layout_marginLeft="3dp" android:src="@mipmap/login_icon_phone"/> <EditText android:id="@+id/username" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@null" android:textSize="10dp" android:imeOptions="actionNext" android:singleLine="true" android:layout_gravity="center_vertical" android:hint="请输入手机号"/> </LinearLayout> <LinearLayout android:id="@+id/layout_pass" app:layout_constraintTop_toTopOf="parent" app:layout_constraintLeft_toLeftOf="parent" android:layout_marginLeft="26dp" android:layout_marginTop="119dp" android:layout_width="228dp" android:layout_height="wrap_content" android:gravity="center_vertical" android:background="@drawable/login_background_name"> <ImageView android:layout_width="17dp" android:layout_height="17dp" android:layout_marginLeft="3dp" android:src="@mipmap/login_icon_pass"/> <EditText android:id="@+id/password" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:background="@null" android:textSize="10dp" android:imeOptions="actionDone" android:singleLine="true" android:hint="请输入验证码" /> <TextView android:id="@+id/login_tv_code" android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="center_vertical|right" android:layout_marginRight="5dp" android:textColor="#01CC5A" android:textSize="10dp" android:background="@null" android:text="获取验证码"/> </LinearLayout> <Button android:id="@+id/login" android:layout_width="228dp" android:layout_height="29dp" android:layout_marginTop="193dp" app:layout_constraintTop_toTopOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" android:textColor="@color/white" android:text="登 录" android:background="@drawable/round_corner_blue_button"/> </androidx.constraintlayout.widget.ConstraintLayout> <LinearLayout android:paddingLeft="7dp" android:layout_width="wrap_content" android:layout_height="wrap_content" app:layout_constraintTop_toBottomOf="@+id/layout_1" app:layout_constraintLeft_toLeftOf="@+id/layout_1" android:gravity="center" android:orientation="horizontal"> <CheckBox android:id="@+id/verify_checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:textColor="#ffc6c6c6" android:drawablePadding="1dp" android:text="登录即代表您同意智学汇" android:textSize="9dp" android:drawableLeft="@drawable/login_checkbox_selector" android:button="@null"/> <TextView android:id="@+id/checkbox_tv" android:layout_marginLeft="4dp" app:layout_constraintTop_toTopOf="@+id/verify_checkbox" app:layout_constraintBottom_toBottomOf="@+id/verify_checkbox" app:layout_constraintLeft_toRightOf="@+id/verify_checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" android:textColor="#ffc6c6c6" android:textSize="9dp" android:visibility="gone" /> <TextView android:id="@+id/fuwu_tv" app:layout_constraintTop_toTopOf="@+id/verify_checkbox" app:layout_constraintBottom_toBottomOf="@+id/verify_checkbox" app:layout_constraintLeft_toRightOf="@+id/checkbox_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="《服务协议》" android:textColor="#FF4F1D" android:textSize="9dp" /> <TextView android:id="@+id/addtv" app:layout_constraintTop_toTopOf="@+id/verify_checkbox" app:layout_constraintBottom_toBottomOf="@+id/verify_checkbox" app:layout_constraintLeft_toRightOf="@+id/fuwu_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="和" android:textColor="#ffc6c6c6" android:textSize="9dp" /> <TextView android:id="@+id/yinse" app:layout_constraintTop_toTopOf="@+id/verify_checkbox" app:layout_constraintBottom_toBottomOf="@+id/verify_checkbox" app:layout_constraintLeft_toRightOf="@+id/addtv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="《隐私条款》" android:textColor="#FF4F1D" android:textSize="9dp" /> </LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout>
页面效果:
java代码:
editText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { Log.i("---","搜索操作执行"); } return false; } });
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通