我有一些 EditText 放在蓝色背景上,对于这些 EditText,我想为文本选择 handle 设置白色(如果可能的话,在 Lollipop 或更新版本上不上传新的 png 图像)
我尝试添加 <item name="android:colorAccent">#ffffffff</item>
按照我的自定义 EditText 的样式,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- EditText on a blue background -->
<style name="BlueBGTextView" parent="@android:style/Widget.Material.Light.EditText">
<item name="android:background">@null</item> <!-- this will also remove all paddings -->
<item name="android:textCursorDrawable">@null</item> <!-- this to use android:textColor as the cursor color. -->
<item name="android:colorAccent">#ffffffff</item>
</style>
<!-- default EditText -->
<style name="AppTheme.EditTextStyle" parent="@android:style/Widget.Material.Light.EditText">
<item name="android:background">@null</item> <!-- this will also remove all paddings -->
</style>
<!-- default Theme -->
<style name="AppTheme" parent="@android:style/Theme.Material.Light.NoActionBar">
<item name="android:editTextStyle">@style/AppTheme.EditTextStyle</item>
<item name="android:colorAccent">#ff0288d1</item> <!-- use to setup the color of the text selection handles -->
<item name="@attr/BlueBGTextViewStyle">@style/BlueBGTextView</item>
</style>
</resources>
但它不起作用 :( 我错过了什么?
最佳答案
您可以在 xml 中指定 textColorHighlight
属性
示例
android:textColorHighlight="#ff0000"
要更改句柄,请使用 colorControlActivated 属性定义样式
<style name="BlueBGTextView">
<item name="colorControlActivated">@android:color/black</item>
</style>
并将其设置为您的 EditText
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/BlueBGTextView"/>
关于android - 如何更改我的其中一个 EditText 的文本选择 handle 的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44197546/