4

I have an EditText on Dark background. My EditTexts are of black color only(if not focused), so not visible properly. How can I change the color? Below is the screenshot. Screenshot

Prakhar
  • 710
  • 6
  • 24

6 Answers6

5

Your question is about the Android theme stuff.Maybe you should set your theme's colorControlNormal value.Just like below:

<style name="Theme.App.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorControlNormal">#YOUR COLOR HEER</item>
</style>

reference here.

Community
  • 1
  • 1
penkzhou
  • 1,200
  • 13
  • 30
0

Try this,

 editText.getBackground().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);
Parth Bhayani
  • 1,894
  • 3
  • 17
  • 35
0

Are you using the AppCompat library? If yes you can override the style attributes colorControlNormal, colorControlActivated and colorControlHighlight.

For example:

<style name="Theme.App.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorControlNormal">@color/your_color_1</item>
    <item name="colorControlActivated">@color/your_color_2</item>
    <item name="colorControlHighlight">@color/your_color_3</item>
</style>
eldivino87
  • 1,425
  • 1
  • 17
  • 30
0

Try this might be help you

      <EditText
            android:textColorHint="@android:color/white"
            android:id="@+id/username"
            style="@style/EditUnderBar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/transparent"
            android:hint="@string/hint_email" />

Add this at your style.xml

 <style name="EditUnderBar" parent="android:Widget.Holo.Light.TextView">
    <item name="android:drawableBottom">@drawable/under_bar</item>
    <item name="android:drawablePadding">3dp</item>
    <item name="android:layout_marginTop">12dp</item>
    <item name="android:paddingLeft">4dp</item>
    <item name="android:textColor">@color/white</item>
    <item name="android:textSize">16sp</item>
</style>

Add this your drawable

 <?xml version="1.0" encoding="utf-8"?>
 <shape
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:shape="rectangle">
  <size android:width="1000dp" android:height="1dp" />
  <solid
     android:color="@color/white"/>
  </shape>

If it not work then add this also

  <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->

    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="android:textColorPrimary">@color/textColorPrimary</item>
    <item name="colorControlNormal">@color/iron</item>
    <item name="colorControlActivated">@color/white</item>
    <item name="colorControlHighlight">@color/white</item>
    <item name="android:textColorHint">@color/white</item>
    <item name="colorAccent">@color/accent</item>
    <item name="android:windowBackground">@color/white</item>
</style>

its work for me

Its might be help you.Good Luck

Shubhank Gupta
  • 833
  • 2
  • 15
  • 35
0

Or try:

android:backgroundTint:”@color/colorWhite”
Zain
  • 37,492
  • 7
  • 60
  • 84
Oladipo Olasemo
  • 2,010
  • 24
  • 31
0

The easiest way to change line color in edittext is to write this in your xml file:

API >= 21:

<EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:backgroundTint="YOUR COLOR" />

API < 21:

<EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:backgroundTint="YOUR COLOR" />
Litva Nick
  • 483
  • 8
  • 11