Android 自定义光标样式
2024-09-02 02:55:14
今天自定义光标,自己切图,不过怎么切都是很宽。不是一个很细的条。我用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属性来使光标底部 向下移动距离 (所以指定负数就是使光标底部向上挪了)
最新文章
- JSON的一点:
- 【Mysql】日期时间格式化
- jquery 单选框整个选中
- Hibernate与iBATIS的比较
- microsoft NLayerApp项目中的层次结构图
- 详解 $().css(&#39;width&#39;)和$().width()的区别
- asp.net mvc 防止重复提交
- Bootstrap3 表单-水平排列的表单
- chrome 错误 ERR_CACHE_READ_FAILURE
- 强大而灵活的的Html解析器——Html Agility Pack
- MVC编程模型
- 就算会用python画颗心,可你依然还是只单身狗
- MyISAM和Innodb区别,为什么?
- PHPsocket、CURL、File_get_contents采集
- BZOJ2004 HNOI2010公交线路(状压dp+矩阵快速幂)
- POI事件模型处理execl导入功能(只支持07版本的execl)
- NOI前各种Idea总结以及各种文本乱堆
- 使用Docker中国官方镜像的加速地址
- Git - Pull Request工作流
- linux环境下python的部署