Lok*_*kio 8 android android-edittext android-styles
绿色来自哪里?我已经尝试更改accentColor属性,该属性适用于应用程序的其他部分,但不在此处.
来自Lollipop的应用程序的屏幕截图.
我怎样才能改变颜色:
也许是未来的一些提示......你是怎么发现的?我一直在遇到所有这些令人困惑的颜色/造型问题.是否有某种列表告诉我,我需要为某个组件覆盖哪个默认颜色或属性?
要更改手柄颜色,您可以按照此处的指定进行操作,使用样式作为
<style name="MyCustomTheme" parent="@style/MyNotSoCustomTheme">
<item name="android:textSelectHandle">@drawable/text_select_handle_middle</item>
<item name="android:textSelectHandleLeft">@drawable/text_select_handle_left</item>
<item name="android:textSelectHandleRight">@drawable/text_select_handle_right</item>
</style>
Run Code Online (Sandbox Code Playgroud)
为了做它以编程方式检查相同的问题,这里的另一个回复是使用反射完成的
try {
final Field fEditor = TextView.class.getDeclaredField("mEditor");
fEditor.setAccessible(true);
final Object editor = fEditor.get(editText);
final Field fSelectHandleLeft = editor.getClass().getDeclaredField("mSelectHandleLeft");
final Field fSelectHandleRight = editor.getClass().getDeclaredField("mSelectHandleRight");
final Field fSelectHandleCenter = editor.getClass().getDeclaredField("mSelectHandleCenter");
fSelectHandleLeft.setAccessible(true);
fSelectHandleRight.setAccessible(true);
fSelectHandleCenter.setAccessible(true);
final Resources res = context.getResources();
fSelectHandleLeft.set(editor, res.getDrawable(R.drawable.text_select_handle_left));
fSelectHandleRight.set(editor, res.getDrawable(R.drawable.text_select_handle_right));
fSelectHandleCenter.set(editor, res.getDrawable(R.drawable.text_select_handle_middle));
} catch (final Exception ignored) {
}
Run Code Online (Sandbox Code Playgroud)
要更改所选的文本颜色,可以textColorHighlight在xml中设置为
android:textColorHighlight="#ff0000"
Run Code Online (Sandbox Code Playgroud)
通过你可以做的风格
<item name="android:textColorHighlight">@color/m_highlight_blue</item>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5230 次 |
| 最近记录: |