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

1

5

I use TabLayout like tabs for ViewPager. When I pressing some tab I get background with strange color of tab. And independently of TabLayout EditText background also in strange view. This result in API 19. And in API 22 all work perfect

aa

When I press back button in toolbar I have similar background with strange color

bb

There is fragment xml where I use TabLayout and Toolbar

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



This is fragment xml where I use EditText

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



This is my style 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>

And in Manifest I set

android:theme="@style/MyMaterialTheme"
Sac answered 21/5, 2016 at 9:21 Comment(4)
Looks like your problem is with rendering nine patch backgrounds. Both the default edit text background and default clickable item background are nine patch images in AppCompat themes. Though I have no idea why would they be broken. You may want to try a clean build or updating your AppCompat dependency to a newer version. Are you sure it's all API 19? Maybe it's just one faulty device?Heath
@MarcinKoziński Yes for all API below 21, I checked it in API 16 (HTC), In API 17(Samsung) problems remainSac
What theme is set on the activity you're showing? What version of AppCompat are you using?Heath
@marcin In activity I set myMaterialTheme. I use AppCompat 23.0.1. But I tried it in 23.4.0, 23.3.0., 23.0.0. this problem remainsSac
N
9

I was able to reproduce the issue on a clean project with one of Android Studio's activity templates. For me the problem was preview version of gradle plugin. Are you using Android Studio 2.2 Preview 1? If yes then find this line in your build.gradle:

    classpath 'com.android.tools.build:gradle:2.2.0-alpha1'

and change it to:

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

For me this solved the problem.

It is reported here: https://code.google.com/p/android/issues/detail?id=210312

EDIT: The fix will be released in Preview 4 next week. You will need to change that line to classpath 'com.android.tools.build:gradle:2.2.0-alpha4'.

Thanks mixel for the link to the correct issue and the information I've pasted as "EDIT:"

Nett answered 22/5, 2016 at 17:31 Comment(5)
I use Android Studio 2.0 RC 1Sac
What version of gradle plugin are you using? You can find that out by looking for line similar to this: classpath 'com.android.tools.build:gradle:2.1.0' in one of your build.gradle filesHeath
You made my day! Thank you very much! I have used is 'classpath 'com.android.tools.build:gradle:+'.Sac
Haha, lesson for you not to use + in versions, because you get unpredictable results. It's an advice shared by lots of people, I guess you now know first hand why :) Anyway, glad I've helped!Heath
Original issue is code.google.com/p/android/issues/detail?id=210312. Others are duplicates. The fix will be released in Preview 4 next week. You will need to change that line to classpath 'com.android.tools.build:gradle:2.2.0-alpha4'.Lucaslucca

© 2022 - 2024 — McMap. All rights reserved.