Android中EditText光标的显示与隐藏方法
作者:彬sir哥 时间:2022-03-01 17:52:35
Android EditText的光标的显示和隐藏
一、java代码
1.编辑框的光标 显示的方法:
editText.setCursorVisible(true);
2.编辑框的光标 隐藏的方法:
editText.setCursorVisible(false);
二、xml代码
android:cursorVisible="true"
<!--或者“false”-->
三、点击编辑框的时候显示光标,没有点击的时候隐藏,可以使用如下
EditText editText = (EditText) findViewById(R.id.edittext);
editText.setCursorVisible(false);
editText.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (MotionEvent.ACTION_DOWN == event.getAction()) {
editText.setCursorVisible(true);
}
return false;
}
});
Android之第一次不显示EditText光标
光标会默认显示在第一个EditText框中,如果不想显示光标,且也不想把该光标移动到下一个EditText框。
解决方法
在该 EditText之前增加一个不可见的LinearLayout
<LinearLayout
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="0px"
android:layout_height="0px" />
来源:https://blog.csdn.net/qq_35091074/article/details/121049084
标签:android,edittext,光标
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
c#根据文件类型获取相关类型图标的方法代码
2022-07-30 10:56:41
SpringBoot登录拦截配置详解(实测可用)
2023-04-22 20:52:21
![](https://img.aspxhome.com/file/2023/5/106135_0s.png)
java设计模式学习之装饰模式
2021-10-02 04:22:54
![](https://img.aspxhome.com/file/2023/7/121937_0s.jpg)
C#判断系统是32位还是64位的方法
2022-04-01 12:44:04
![](https://img.aspxhome.com/file/2023/9/108799_0s.png)
RxJava2.x实现定时器的实例代码
2023-08-06 17:41:01
SpringBoot整合screw实现数据库文档自动生成的示例代码
2023-11-29 05:30:15
![](https://img.aspxhome.com/file/2023/9/60579_0s.png)
javaweb页面附件、图片下载及打开(实现方法)
2023-11-25 05:33:44
Java关键字instanceof用法及实现策略
2023-09-23 06:05:38
![](https://img.aspxhome.com/file/2023/0/58560_0s.png)
轻松掌握Java建造者模式
2023-11-06 15:24:38
springboot为异步任务规划自定义线程池的实现
2022-12-05 01:13:02
![](https://img.aspxhome.com/file/2023/1/95971_0s.png)
Java 中的 clone( ) 和 new哪个效率更高
2023-11-09 05:27:44
![](https://img.aspxhome.com/file/2023/6/59326_0s.png)
java WebSocket 服务端实现代码
2022-09-28 00:30:52
![](https://img.aspxhome.com/file/2023/8/92668_0s.png)
Java中ResultSetMetaData 元数据的具体使用
2021-06-25 12:38:13
![](https://img.aspxhome.com/file/2023/2/65732_0s.png)
基于RxJava实现酷炫启动页
2023-09-26 21:50:47
![](https://img.aspxhome.com/file/2023/7/86007_0s.gif)
IDEA部署JavaWeb项目到Tomcat服务器的方法
2023-11-02 23:21:22
详解Java中的final关键字
2023-02-20 17:29:50
Java MyBatis本地缓存原理详解
2023-01-30 18:20:36
![](https://img.aspxhome.com/file/2023/3/79213_0s.webp)
详解SpringMVC和MyBatis框架开发环境搭建和简单实用
2022-03-11 13:54:51
![](https://img.aspxhome.com/file/2023/8/118818_0s.png)
Java发送邮件遇到的常见需求汇总
2021-10-07 14:51:02
C#创建安全的字典(Dictionary)存储结构
2023-03-17 22:11:51