2016-05-21 11 views
5

Ich verwende TabLayout wie Registerkarten für ViewPager. Wenn ich einen Tab drücke, bekomme ich einen Hintergrund mit einer seltsamen Tab-Farbe. Und unabhängig von TabLayout EditText Hintergrund auch in seltsamer Ansicht. Dieses Ergebnis in API 19. Und in API 22 alle arbeiten perfekt

aaDefekte Standardhintergründe, wie für EditText oder gedrückten Zustand in TabLayout und Toolbar

Wenn ich Schaltfläche in Symbolleiste drücken zurück Ich habe ähnliche Hintergrund mit seltsamen Farbe

bb

Es gibt XML-Fragment, wo ich TabLayout verwenden und 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> 



Dies ist Fragment xml wo ich 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" 
      /> 



Das ist mein Stil 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> 

Und in Manifest stellte ich

android:theme="@style/MyMaterialTheme" 
+0

Sieht aus wie Ihr Problem mit Rendering neun Patch Hintergründe ist. Sowohl der standardmäßige Bearbeitungs-Texthintergrund als auch der standardmäßige anklickbare Objekt-Hintergrund sind neun Patch-Abbilder in AppCompat-Designs. Obwohl ich keine Ahnung habe, warum sie gebrochen werden würden. Möglicherweise möchten Sie einen sauberen Build versuchen oder Ihre AppCompat-Abhängigkeit auf eine neuere Version aktualisieren. Sind Sie sicher, dass es alles API 19 ist? Vielleicht ist es nur ein defektes Gerät? –

+0

@ MarcinKoziński Ja für alle API unter 21, ich habe es in API 16 (HTC) überprüft, in API 17 (Samsung) Probleme bleiben – eluuu

+0

Welches Thema ist auf die Aktivität eingestellt, die Sie zeigen? Welche Version von AppCompat verwenden Sie? –

Antwort

9

Ich war in der Lage, das Problem auf einem sauberen Projekt mit einem reproduzieren Android Studio-Aktivitätsvorlagen Für mich war das Problem eine Vorschauversion von Gradle Plugin. Verwenden Sie Android Studio 2.2 Preview 1? Wenn ja, dann diese Zeile finden in Ihrem build.gradle:

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

und ändern Sie es zu:

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

Für mich gelöst das Problem.

Es wird hier berichtet: https://code.google.com/p/android/issues/detail?id=210312

EDIT: Das Update wird in der Vorschau 4 nächste Woche veröffentlicht werden. Sie müssen diese Zeile in den Klassenpfad "com.android.tools.build:gradle:2.2.0-alpha4" ändern.

Dank Mixel für den Link auf die korrekte Ausgabe und die Informationen, die ich als eingefügt haben „EDIT:“

+0

Ich benutze Android Studio 2.0 RC 1 – eluuu

+0

Welche Version von Gradle Plugin verwenden Sie? Sie können das herausfinden, indem Sie nach einer Zeile ähnlich der folgenden suchen: 'classpath 'com.android.tools.build: grandle: 2.1.0'' in einer Ihrer' build.gradle' Dateien –

+0

Sie haben meinen Tag gemacht! Vielen Dank! Ich habe verwendet 'classpath' com.android.tools.build:gradle:+ '. – eluuu