Broken default backgrounds, e.g. for EditText or clicked state in TabLayout and toolbar

I use TabLayout as tabs for ViewPager. When I click on a tab, I get a background with a strange tab color. And regardless of the background, the TabLayout EditText is also in a weird view. This result is in API 19. And in API 22, everything works fine

aa

When I click the button on the toolbar, I have a similar background with a strange color

bb

There is an xml snippet where I use TabLayout and the 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 the xml snippet 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 xml style

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

 android:theme="@style/MyMaterialTheme" 
+5
source share
1 answer

I was able to reproduce the problem in a clean project with one of the Android Studio activity patterns. For me, the problem was the preview version of the gradle plugin. Are you using Android Studio 2.2 Preview 1? If so, find this line in 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.

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 this line to classpath 'com.android.tools.build: gradle: 2.2.0-alpha4'.

Thanks to mixel for linking to the correct problem and the information I inserted as "EDIT:"

+9
source

All Articles