10

Ich möchte mit der neuen Design Support Library ein bestimmtes Aussehen erreichen und ich kann nicht aufhören, einen seltsamen Bug zu sehen.TabLayout innerhalb der Toolbar

Hier the screencast with the desired output (nicht mit DSL getan) Und the ouput I get using DSL.

Die Symbolleiste + Tabs ist in einer Aktivität mit einem viewpager und der recyclerView ist innerhalb eines Fragments innerhalb des viewpager (Adapter tatsächlich, aber Sie bekommen meine Nummer)

-Code für die Aktivität:

<android.support.design.widget.CoordinatorLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:fab="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar_main" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:elevation="4dp" 
      app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
      app:layout_scrollFlags="scroll|enterAlways"> 

      <android.support.design.widget.TabLayout 
       android:id="@+id/tabs" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       app:tabIndicatorColor="@color/white" 
       app:tabTextColor="@color/selected_text" 
       app:tabSelectedTextColor="@color/white"/> 

     </android.support.v7.widget.Toolbar> 

    </android.support.design.widget.AppBarLayout> 

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

    <android.support.design.widget.SupportFloatingActionsMenu 
      ...> 
      /* Code for a fancy fab w/ menu */ 

    </android.support.design.widget.SupportFloatingActionsMenu> 

</android.support.design.widget.CoordinatorLayout> 

Für das Fragment, das das recyclerView enthält:

<android.support.design.widget.CoordinatorLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.insa.burnd.view.MainActivity.NewsfeedFragment" 
    android:id="@+id/fragment_newsfeed"> 

    <android.support.v4.widget.SwipeRefreshLayout 
     android:id="@+id/swipe_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/recyclerView" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 

    </android.support.v4.widget.SwipeRefreshLayout> 

</android.support.design.widget.CoordinatorLayout> 

der Java-Code ist ziemlich Standard, bing ich den viewpager die Registerkarten ... etc.

Vielen Dank im Voraus für Ihre Hilfe :)!

+0

Ändert sich irgendetwas, wenn Sie 'CoordinatorLayout' und' SwipeRefreshLayout' aus dem Layout des Fragments entfernen? – ianhanniballake

+0

Ich bekomme den gleichen Fehler. – Mehdi

+0

Können Sie es erneut mit der neu veröffentlichten Version 22.2.1 (https://plus.google.com/+AndroidDevelopers/posts/XTTNCPviwpj) versuchen? – ianhanniballake

Antwort

1

Diese und viele andere Fehlerbehebungen wurden in version 22.2.1 der Design Library behoben. Bitte stellen Sie sicher, dass Ihre build.gradle Datei die neueste Version referenziert.

Verwandte Themen