How to change EditText bubble color (under cursor) in android?
Asked Answered
L

6

33

How to change the color of EditText bubble in android, I could do change the cursor drawable but I want change color of Bubble, please share idea on it.

Reference screenshot:

enter image description here

Any help would be appreciated.

Lamellicorn answered 11/2, 2016 at 11:18 Comment(1)
So you can set custom theme, as here medium.com/@werder630/…Kremenchug
A
24

Change the color in your res/values/styles.xml. The bubble uses colorAccent:

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
    <!-- Other theme overrides here -->
    <item name="colorAccent">@color/Gray2</item>
</style>

In the above <item name="colorAccent">@color/Gray2</item> is the line where you put the color you want for your bubble.

Andraandrade answered 11/2, 2016 at 11:25 Comment(0)
S
35

You can change all your EditText bubbles and bar colors setting the accent color in your AppTheme.

<style name="AppTheme" parent="Base.Theme.AppCompat.Light">
    <item name="colorPrimary">@color/indigo</item>
    <item name="colorAccent">@color/pink</item>
</style>

Or you could just change one single EditText with the android:theme attribute of your component.

<style name="MyEditText" parent="Theme.AppCompat.Light">  
   <item name="colorControlNormal">@color/indigo</item>
   <item name="colorControlActivated">@color/pink</item>
</style>  

<EditText  
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Hint text"
    android:theme="@style/MyEditText"
    />
Subphylum answered 11/2, 2016 at 11:32 Comment(2)
Looks like applying theme to a single View will work with Android Support Library v22.1 and later, according to developer.android.com/guide/topics/ui/look-and-feel/…. See release notesMazel
Also, android-developers.googleblog.com/2015/04/…Mazel
A
24

Change the color in your res/values/styles.xml. The bubble uses colorAccent:

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
    <!-- Other theme overrides here -->
    <item name="colorAccent">@color/Gray2</item>
</style>

In the above <item name="colorAccent">@color/Gray2</item> is the line where you put the color you want for your bubble.

Andraandrade answered 11/2, 2016 at 11:25 Comment(0)
N
3

http://developer.android.com/training/material/theme.html#ColorPalette

<resources>
  <!-- inherit from the material theme -->
  <style name="AppTheme" parent="android:Theme.Material">
    <!-- Main theme colors -->
    <!--   your app branding color for the app bar -->
    <item name="android:colorPrimary">@color/primary</item>
    <!--   darker variant for the status bar and contextual app bars -->
    <item name="android:colorPrimaryDark">@color/primary_dark</item>
    <!--   theme UI controls like checkboxes and text fields -->
    <item name="android:colorAccent">@color/accent</item>
  </style>
</resources>

And check this: theme UI controls like checkboxes and text fields

<!--   theme UI controls like checkboxes and text fields -->
        <item name="android:colorAccent">@color/accent</item>

Was it so hard to find? :)

Narayan answered 11/2, 2016 at 11:42 Comment(0)
P
3

You need to change your theme colorControlActivated color.

source: the default implementation of text_select_handle in Android Source code.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 The Android Open Source Project

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/text_select_handle_middle_mtrl_alpha"
android:tint="?attr/colorControlActivated" />
Paleobiology answered 9/9, 2016 at 16:27 Comment(0)
N
1

In my case I was able to change the color by changing the value of android:colorControlActivated in my themes file:

<item name="android:colorControlActivated">?attr/colorAccent</item>

Natoshanatron answered 15/6, 2022 at 13:33 Comment(0)
S
0

You should change "colorAccent" and in order not to change this parameter for the whole application you can use ThemeOverlay. You can read more detailed in this article, the last theme "Cursor and Selection"

Swell answered 11/3, 2020 at 19:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.