10

I want to achieve a certain look with the new Design Support Library and I can't stop seeing a weird bug.

Here's the screencast with the desired output (not done with DSL) And the ouput I get using DSL.

The toolbar+tabs is in an activity with a viewpager, and the recyclerView is inside a fragment within the viewpager (the adapter actually, but you get my point)

Code for the activity :

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

For the fragment containing the recyclerView :

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

The java code is pretty standard, I bing the viewpager to the tabs... etc.

Thank you in advance for your help :) !

Mehdi
  • 713
  • 9
  • 19
  • Does anything change when you remove the `CoordinatorLayout` and `SwipeRefreshLayout` from the fragment's layout? – ianhanniballake Jun 30 '15 at 17:27
  • I get the same glitch. – Mehdi Jun 30 '15 at 18:29
  • Can you try it again with the newly released [version 22.2.1](https://plus.google.com/+AndroidDevelopers/posts/XTtNCPviwpj)? – ianhanniballake Jul 21 '15 at 23:16
  • Works like a charm ! You guys are awesome :) ! – Mehdi Jul 22 '15 at 18:19
  • You asked the same question/code here: http://stackoverflow.com/questions/31161965/appbarlayout-with-recyclerview-in-nested-fragment. – Jared Burrows Jul 22 '15 at 20:16
  • Hey @mehdi I'm trying to do the same thing, however the the tab on the far left will not go to the edge of the screen. Do you know I can make this happen. Setting tabGravity="fill" is not the issue as that works fine if I just move the TabLayout below the Toolbar. I have a feeling something in the Toolbar is taking up space on the left. – b.lyte Nov 24 '15 at 22:29
  • Did you try with the newest version of the Design Library, this seems to have fixed the issue for me ! – Mehdi Jan 01 '16 at 21:24

1 Answers1

2

This and many other bug fixes were fixed in version 22.2.1 of the Design Library. Please make sure your build.gradle file references the newest version.

ianhanniballake
  • 191,609
  • 30
  • 470
  • 443