Why does my recycleview not respect Match Parent?

Asked

Viewed 53 times

0

I have a cordinatorlayout that contains a recycleview, however it fills the whole screen, and this all set as match_parent, including the recycleview card inserir a descrição da imagem aqui XML:

<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.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="false"
            app:layout_scrollFlags="scroll|enterAlways">

            <android.support.constraint.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <com.nex3z.togglebuttongroup.SingleSelectToggleGroup
                    android:id="@+id/group_choices"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="4dp"
                    app:layout_collapseMode="pin"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    app:tbgCheckedButton="@+id/tudo">

                    <com.nex3z.togglebuttongroup.button.LabelToggle
                        android:id="@+id/tudo"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:padding="2dp"
                        android:text="Tudo"
                        app:tbgMarkerColor="@color/colorPrimary" />

                    <com.nex3z.togglebuttongroup.button.LabelToggle
                        android:id="@+id/unidade"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:padding="2dp"
                        android:text="Praia da Costa"
                        app:tbgMarkerColor="@color/colorPrimary" />
                </com.nex3z.togglebuttongroup.SingleSelectToggleGroup>
            </android.support.constraint.ConstraintLayout>

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

    <android.support.v7.widget.RecyclerView
        android:id="@+id/rv_noticias"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

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

1 answer

0

Wrap your RecyclerView in a Layout (Framelayout, for example). This layout should also have android:layout_width="match_parent"

Move the app:layout_behavior="@string/appbar_scrolling_view_behavior" for that Framelayout

<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.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="false"
            app:layout_scrollFlags="scroll|enterAlways">

            <android.support.constraint.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <com.nex3z.togglebuttongroup.SingleSelectToggleGroup
                    android:id="@+id/group_choices"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="4dp"
                    app:layout_collapseMode="pin"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    app:tbgCheckedButton="@+id/tudo">

                    <com.nex3z.togglebuttongroup.button.LabelToggle
                        android:id="@+id/tudo"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:padding="2dp"
                        android:text="Tudo"
                        app:tbgMarkerColor="@color/colorPrimary" />

                    <com.nex3z.togglebuttongroup.button.LabelToggle
                        android:id="@+id/unidade"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:padding="2dp"
                        android:text="Praia da Costa"
                        app:tbgMarkerColor="@color/colorPrimary" />

                </com.nex3z.togglebuttongroup.SingleSelectToggleGroup>

            </android.support.constraint.ConstraintLayout>

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

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

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

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

    </FrameLayout>

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.