caoxinyu

今天自定义光标,自己切图,不过怎么切都是很宽。不是一个很细的条。我用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属性来使光标底部 向下移动距离 (所以指定负数就是使光标底部向上挪了)

分类:

技术点:

相关文章:

  • 2017-12-16
  • 2021-12-16
  • 2021-11-04
  • 2021-09-17
  • 2021-08-17
  • 2021-11-24
  • 2018-10-22
  • 2019-03-21
猜你喜欢
  • 2021-10-27
  • 2021-10-16
  • 2021-10-29
  • 2021-10-29
  • 2021-10-26
  • 2021-08-01
相关资源
相似解决方案