软件编程
位置:首页>> 软件编程>> Android编程>> 解决EditText不显示光标的三种方法(总结)

解决EditText不显示光标的三种方法(总结)

作者:jingxian  发布时间:2023-09-19 08:05:10 

标签:edittext,光标,不显示

解决方法有以下3种

1、在Edittext中加入以下属性


android:cursorVisible="true"
android:textCursorDrawable="@null"

2、在Edittext中加入以下属性


android:cursorVisible="true"
android:textCursorDrawable="@drawable/test_cursor"

对应的drawable文件

<?xml version="1.0" encoding="utf-8"?>
 <shape xmlns:android="http://schemas.android.com/apk/res/android"
   android:shape="rectangle">

<size android:width="1dp" />

<span style="font-family: Arial, Helvetica, sans-serif;">

<!-- 光标宽度可以自己定义 --></span>

<solid android:color="#008000" />

<!-- 光标颜色可以自己定义 -->
 </shape>

3、如果以上没有效果就请用这个

明确指定EditText的inputType属性值inputType属性中的textCapSentences

不要用这个,国内手机好像没有用到这个,个人证实而已,用text或者textMultiLine


android:inputType="text|textMultiLine"

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com