Как изменить цвет пузырька EditText (под курсором) в android? - программирование
Подтвердить что ты не робот

Как изменить цвет пузырька EditText (под курсором) в android?

Как изменить цвет пузырька EditText в android, я мог бы изменить курсор, но я хочу изменить цвет Bubble, пожалуйста, поделитесь идеей на нем.

Ссылка на скриншот:

введите описание изображения здесь

Любая помощь будет оценена по достоинству.

4b9b3361

Ответ 1

Измените цвет в res/values/styles.xml. В пузыре используется colorAccent:

<!-- Base application theme. -->
    <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/DarkBlue</item>
        <item name="colorPrimaryDark">#01517f</item>
        <item name="colorAccent">@color/Gray2</item>

В приведенной выше <item name="colorAccent">@color/Gray2</item> есть строка, в которую вы помещаете цвет, который вы хотите для своего пузыря.

Ответ 2

Вы можете изменить все ваши EditText пузырьки и бар colors, установив цвет акцента в AppTheme.

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

Или вы можете просто изменить один единственный EditText с помощью атрибута android:theme вашего компонента.

<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"
    />

Ответ 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>

И проверьте это: параметры пользовательского интерфейса темы, такие как checkboxes и text fields

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

Было ли так трудно найти?:)

Ответ 4

Вам нужно изменить цвет вашей темы colorControlActivated.

source: стандартная реализация text_select_handle в исходном коде Android.

<?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" />