zoukankan      html  css  js  c++  java
  • 设置Editext的光标宽高与颜色

    转载请标明: http://77blogs.com/?p=555

    在Editext的布局属性上加上

    android:textCursorDrawable="@drawable/cursor_shape"

    cursor_shape如下:

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

    事实证明:设置android:height无效,应该用padding的方法。

    top设置为-2dp :让光标顶部下移2dp

    bottom设置为-2dp:让光标底部上移2dp

    这样子光标的高度就变小了4dp

    从下面的源码可以大概看出原因:

    private void updateCursorPosition(int cursorIndex, int top, int bottom, float horizontal) {
        ...
     
        mCursorDrawable[cursorIndex].getPadding(mTempRect);
     
        ...
     
        mCursorDrawable[cursorIndex].setBounds(left, top - mTempRect.top, left + width,
                bottom + mTempRect.bottom);
    }
  • 相关阅读:
    java泛型
    跨域传递
    laravel的一些语法
    去重
    laravel的一些查询语句
    mysql把之前表单进行拆分
    Laravel5.1接收json数据
    thinkphp5 composer安装验证码
    关于地图经纬度的问题
    tp5分组查询
  • 原文地址:https://www.cnblogs.com/tangZH/p/9636816.html
Copyright © 2011-2022 走看看