【Android】设置光标颜色和图标

创建主题

该主题可以更改文字下方拖拽手柄的颜色

xml 复制代码
<?xml version="1.0" encoding="utf-8"?>
<resources>
  <style name="RedTextCursor">
    <item name="android:colorControlActivated">#FF0000</item>
  </style>
</resources>
应用主题到Dialog/PopupWindow/DialogFragment/Activity

根据组件类型,使用对应的主题设置方式

kotlin 复制代码
class MyDialog : Dialog(context, R.style.RedTextCursor)
创建光标资源

用于改变光标颜色和形状

xml 复制代码
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <size android:width="@dimen/dp_2" />
    <solid android:color="@color/primary_200" />
</shape>
设置TextView光标
xml 复制代码
<TextView
	android:textCursorDrawable="@drawable/shape_cursor_red"/>
相关推荐
白菜欣1 天前
Linux — 进程控制
android·linux·运维
小酒窝.1 天前
【cursor】如何关闭自动修改?设置每处修改都要手动确认
cursor·ai 应用
俩个逗号。。1 天前
Gradle 踩过的坑
android
土星碎冰机1 天前
ai自学笔记(3.安卓篇,制作app
android·笔记·ai
随遇丿而安1 天前
专题:Glide / Coil / Fresco,不是三种写法,而是三套图片加载思路
android
只可远观2 天前
Android 自动埋点(页面打开 / 关闭 + 点击事件)完整方案
android·kotlin
私人珍藏库2 天前
【Android】小小最新AI--千变万化扮演任何角色--沉浸式互动
android·app·工具·软件·多功能
zh_xuan2 天前
Android MVI架构
android·mvi
测试开发-学习笔记2 天前
Airtest+Poco快速上手
android·其他
李斯维2 天前
Android Jetpack 简介:由来和演进
android·android studio·android jetpack