今天自定义光标,自己切图,不过怎么切都是很宽。不是一个很细的条。我用ps花了一个像素的直线,放上去还是不行。后来在网上找到方法,那就是用shape。不得不说,shape真的是太吊了。

给EditText指定Android:textCursorDrawable属性

 <EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textColorHint="@color/colorPure"
android:inputType="textEmailAddress"
android:background="@drawable/apptheme_edit_text_holo_light"
android:textCursorDrawable="@drawable/cursor_purl" android:hint="Password"/>

cursor_purl是一个资源文件

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<size
android:width="1dip" />
<solid
android:color="@color/colorPure" />
<!--<padding-->
<!--android:top="0sp"-->
<!--android:bottom="0sp" />-->
</shape>

设置成1dip宽度正好!

补充

通过width来指定光标的宽度

通过top属性来使光标顶部 向上移动距离

通过bottom属性来使光标底部 向下移动距离 (所以指定负数就是使光标底部向上挪了)

最新文章

  1. JSON的一点:
  2. 【Mysql】日期时间格式化
  3. jquery 单选框整个选中
  4. Hibernate与iBATIS的比较
  5. microsoft NLayerApp项目中的层次结构图
  6. 详解 $().css(&#39;width&#39;)和$().width()的区别
  7. asp.net mvc 防止重复提交
  8. Bootstrap3 表单-水平排列的表单
  9. chrome 错误 ERR_CACHE_READ_FAILURE
  10. 强大而灵活的的Html解析器——Html Agility Pack
  11. MVC编程模型
  12. 就算会用python画颗心,可你依然还是只单身狗
  13. MyISAM和Innodb区别,为什么?
  14. PHPsocket、CURL、File_get_contents采集
  15. BZOJ2004 HNOI2010公交线路(状压dp+矩阵快速幂)
  16. POI事件模型处理execl导入功能(只支持07版本的execl)
  17. NOI前各种Idea总结以及各种文本乱堆
  18. 使用Docker中国官方镜像的加速地址
  19. Git - Pull Request工作流
  20. linux环境下python的部署

热门文章

  1. 服务器raid状态监控
  2. 使用mongoDB时错误解决
  3. Node.js-ReferenceError: _filename is not defined
  4. 如何用C# 动态创建Access数据库和表?
  5. java——栈和队列 面试题
  6. ZOJ - 2112 Dynamic Rankings(BIT套主席树)
  7. ABI (应用程序二进制接口)
  8. Java 截屏工具类
  9. Java中阻塞队列的使用
  10. Win10远程桌面连接树莓派3时出现错误:由于安全设置