损坏的默认背景,例如 EditText 或 TabLayout 和 Toolbar 中的按下状态

Broken default backgrounds, like for EditText or pressed state in TabLayout and Toolbar

我使用 TabLayout 就像 ViewPager 的标签一样。当我按下某个选项卡时,我得到带有奇怪颜色选项卡的背景。独立于 TabLayout 的 EditText 背景也在奇怪的视图中。这导致 API 19。在 API 22 中,所有工作都完美

当我按下工具栏中的后退按钮时,我有类似的背景,但颜色很奇怪



在我使用 TabLayout 和 Toolbar

的地方有片段 xml
    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
                </android.support.v7.widget.Toolbar>


            <android.support.design.widget.TabLayout
                android:id="@+id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:tabMode="fixed"
                app:tabGravity="fill"
                app:tabIndicatorHeight="0dp"
                android:layout_marginBottom="10dp"
                />
        </android.support.design.widget.AppBarLayout>

        <android.support.v4.view.ViewPager
            android:id="@+id/viewpager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            />
    </android.support.design.widget.CoordinatorLayout>



这是我使用 EditText 的片段 xml

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:text="Заполните поля чтобы войти"
            android:textColor="@color/black"/>
         <EditText
                    android:id="@+id/edt_firstname"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Логин*"
                    android:textSize="15sp"
                    android:textColorHighlight="#F14040"
                    android:layout_marginTop="10dp"
                    style="@style/Base"
                    android:backgroundTint="@color/colorPrimary"
                    android:inputType="phone"
                    android:maxLength="13"
                    />
        <EditText
            android:id="@+id/lastname"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Пароль"
            android:textSize="15sp"
            android:textColorHighlight="#F14040"
            android:layout_marginTop="10dp"
            style="@style/Base"
            android:backgroundTint="@color/colorPrimary"
            android:inputType="textPassword"
            />



这是我的风格xml

<style name="MyMaterialTheme" parent="MyMaterialTheme.Base">
</style>

<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorPrimary</item>
    <item name="searchViewStyle">@style/SearchViewMy</item>
</style>

<style name="Theme.App.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorControlNormal">#c5c5c5</item>
    <item name="colorControlActivated">@color/colorPrimary</item>
    <item name="colorControlHighlight">@color/colorPrimary</item>
</style>

我在清单中设置了

android:theme="@style/MyMaterialTheme"

我能够使用 Android Studio 的 activity 模板之一在干净的项目上重现该问题。对我来说,问题是 gradle 插件的预览版。您使用的是 Android Studio 2.2 Preview 1 吗?如果是,则在 build.gradle:

中找到这一行
    classpath 'com.android.tools.build:gradle:2.2.0-alpha1'

并将其更改为:

    classpath 'com.android.tools.build:gradle:2.1.0'

对我来说,这解决了问题。

这里报道:https://code.google.com/p/android/issues/detail?id=210312

编辑:修复将在下周的预览版 4 中发布。您需要将该行更改为类路径 'com.android.tools.build:gradle:2.2.0-alpha4'.

感谢 mixel link 解决了正确的问题以及我粘贴为 "EDIT:"

的信息