@style/ThemeOverlay.AppCompat.Dark.ActionBar

Edittext color white in appcompat 22.2

EDIT 2: This is due to the line

<item name="theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>

in styles.xml

. I use this to display light (white) texts and a back home button in ToolBar

. If I change this to <item name="theme">@style/ThemeOverlay.AppCompat.Light</item>

, it EditText

works as expected, but the color of the ToolBar

text and back home changes to dark (black).

Since I am using a dark color ToolBar

, I would like to show the text and the home button in light (white) color.

I tried using <item name="android:theme">...</item>

instead <item name="theme">...</item>

But nothing worked for me. The toolbar text and Back button are still dark! Anyone got it? Help me!

ACTUAL QUESTION:

As appcompat-v7:22.2.0

I have used EditText

. I am using the following theme forActivity

<style name="AppThemeNoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/myPrimaryColor</item>
    <item name="colorPrimaryDark">@color/myPrimaryDarkColor</item>
    <item name="colorAccent">@color/myAccentColor</item>
    <item name="android:windowBackground">@color/myWindowBackground</item>
    <item name="theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
    <item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
    <item name="colorControlHighlight">#0000AA</item>
</style>

      

But the color EditText

is white. The summary, hint and text are all in white. I heard there is a bug in AppCompat

But how to fix this problem?

EDIT 1: Adding more information

XML file:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_marginTop="@dimen/marintopforelements"
          android:gravity="center"
          android:orientation="vertical"
          android:padding="10dp"
          android:paddingTop="@dimen/templatePaddingTop">

          <android.support.v7.widget.AppCompatEditText
                android:id="@+id/emailresponse"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="left|center"
                android:layout_marginLeft="@dimen/examtextdiff"
                android:imeOptions="actionNext"
                android:inputType="textEmailAddress"
                android:minLines="2"
                android:paddingRight="5dp"
                android:textSize="@dimen/inboxTabTextSize"/>

</LinearLayout>

      

colors.xml

<color name="myPrimaryColor">#3F51B5</color>
<color name="myPrimaryDarkColor">#FF304081</color>
<color name="myAccentColor">#3F51B5</color>

      

So before when I used AppCompat-V7:21

It went like below:enter image description here

But after upgrading to appcompat-v7:22.2.0

It is like below. enter image description here

So if he focused his approximation like below enter image description here

Only this line of the cursor has the specified accent color. But the tip and text are always in white! And it happens even in EditText

and AppCompatEditText

Hope this helps

+3


source to share


3 answers


Okay, I fixed it!

What I was doing is I want to display ToolBar

content in white since my ToolBar is dark, so I used this line

<item name="theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>

in styles.xml

This works great with appcompat-v7:21.+

.

But in appcompat-v7:22.2.0

since app:theme

depreciated (mentioned in his answer by @ Guillaume Imbert).

So there was confusion here. I haven't used "app: theme" anywhere in my project, but it still keeps showing me a warning. So again I found google and found the link.



Which brings me to the next blog by Chris Banes made it clear about it.

Now I have removed <item name="theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>

from styles.xml

. Therefore my content is ToolBar

dark (black).

Finally, adding android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"

to mine ToolBar

did the trick. So my toolbar code looks like

<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="@dimen/action_bar_size_x2"
    android:background="@color/myPrimaryColor"
    android:minHeight="?attr/actionBarSize"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>

      

So it might help someone.

Thanks for giving me a good edge to both @reVerse and @Guillaume Imbert. Without your answers, I would not have been able to fix this. Thank you so much:)

+2


source


I would recommend that you create a theme / style just for yours EditText

. Appcompat

uses the default android:textColorSecondary

as the color for the bottom line of the EditText, although you haven't defined this in your theme, so it's hard to see why your bottom line, text, and tooltip are all white.

Here is an example of a separate topic for EditText

<style name="ThemeEditTextLight">
    <!-- bottom line color -->
    <item name="colorControlNormal">#000000</item>
    <!-- text color -->
    <item name="android:textColor">#000000</item>
    <!-- hint text color -->
    <item name="android:textColorHint">#BDBDBD</item>
</style>

      



And then just set the theme to your EditText:

 <EditText
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:hint="My hint"
     android:theme="@style/ThemeEditTextLight" />

      

This approach gives you more control over the color of your EditTexts.

+3


source


First, you must use EditText, not compatible one. At run time, the support library replaces EditText with appcompat only when needed.

As for your problem, appcompat 22.2 suggests using android: theme instead of app: theme . I think the theme theme in your style was not applied with the previous version of appcompat and now it is.

BTW, I don't know if using a theme theme in a theme is good practice.

+1


source







All Articles