Notice: 函数 WP_Scripts::localize 的调用方法不正确$l10n 参数必须是一个数组。若要将任意数据传递给脚本,请改用 wp_add_inline_script() 函数。 请查阅调试 WordPress来获取更多信息。 (这个消息是在 5.7.0 版本添加的。) in /data/www/appblog/wp-includes/functions.php on line 6131

Android设置EditText光标位置、粗细颜色

光标位置

  • 如果设置的是起始位置,只需要在xml文件中加上
android:gravity="right"

即可让光标默认在最右侧闪烁。

  • 如果设置指定的位置,需要在代码中
EditText et = (EditText) findViewById(R.id.editText);
et.setSelection(et.getText().toString().length());

指定即可。length是在文字最后端闪烁。

粗细颜色

设置光标颜色和粗细。需要在drawable目录下新建的shape.xml文件中

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <size android:width="1dp" />
    <solid android:color="#008000" />
</shape>

在EditText设置

android:textCursorDrawable="@drawable/shape"

如果设置

android:textCursorDrawable="@null"

则默认跟textColor颜色一样

上一篇 Android Activity设置全屏显示
下一篇 Android ScrollView中软键盘顶上整个布局