RecyclerView未显示在协调器布局中

时间:2019-04-02 00:08:55

标签: android android-layout

我遇到了将ConstraintLayout转换为CoordinatorLayout的问题,现在我的RecyclerViews为空。对为什么会发生这种情况有任何想法吗?我的xml如下:

<?xml version="1.0" encoding="utf-8"?>
<layout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    >

    <data>

        <import type="me.tatarka.bindingcollectionadapter2.LayoutManagers" />
        <import type="com.google.android.gms.ads.AdSize" />
        <import type="android.view.View" />

        <variable
            name="viewModel"
            type="com.kinetoplay.fantasymovieleague.ui.cineplex.CineplexBuilderViewModel" />
    </data>

    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/relativeLayout2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        android:background="@color/velvet_dark"
        tools:context="com.kinetoplay.fantasymovieleague.ui.cineplex.CineplexBuilderActivity">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/appBarLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/AppTheme.AppBarOverlay"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

            <android.support.v7.widget.Toolbar
                android:id="@+id/cinbuilder_toolbar"
                android:layout_width="match_parent"
                android:layout_height="?android:attr/actionBarSize"
                app:contentInsetStartWithNavigation="0dp"
                app:popupTheme="@style/AppTheme.PopupOverlay"
                app:title="Cineplex Builder"
                app:titleTextAppearance="@style/Toolbar.TitleText"
                app:titleTextColor="@color/black">

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

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

        <!-- Ad -->
        <com.kinetoplay.fantasymovieleague.ads.FMLAdView
            android:id="@+id/top_ad"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="50dp"
            android:paddingLeft="40dp"
            android:paddingTop="8dp"
            app:FMLAdSize="@{AdSize.BANNER}"
            app:FMLAdUnit="@{viewModel.headerAd}"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/ll_header_wrapper"
            app:layout_constraintTop_toTopOf="parent" />

        <android.support.v7.widget.RecyclerView
            android:id="@+id/cinebuilder_reyclerview"
            android:layout_width="match_parent"
            android:layout_height="572dp"
            android:layout_marginTop="140dp"
            android:scrollbars="horizontal"
            android:visibility="visible"
            app:itemBinding="@{viewModel.moviesBinding}"
            app:items="@{viewModel.movies}"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            tools:listitem="@layout/row_cineplex_builder_movie"></android.support.v7.widget.RecyclerView>

        <android.support.constraint.ConstraintLayout
            android:id="@+id/cl_bottom_sheet"
            android:layout_width="match_parent"
            android:layout_height="330dp"
            android:layout_marginTop="10dp"
            android:background="@color/velvet"
            android:paddingStart="0dp"
            android:paddingTop="24dp"
            android:paddingEnd="0dp"
            android:paddingBottom="24dp"
            app:behavior_hideable="true"
            app:behavior_peekHeight="100dp"
            app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

            <TextView
                android:id="@+id/tv_motorcycle_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Testing 123"
                android:textColor="@color/white"
                android:textSize="17sp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toEndOf="@id/gl_left_gutter"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                tools:text="Ben's Bike" />


            <android.support.v7.widget.RecyclerView
                android:id="@+id/cinebuilder_projection_reyclerview"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"
                android:layout_width="match_parent"
                android:layout_height="511dp"
                android:layout_marginTop="10dp"
                app:itemBinding="@{viewModel.projectionBinding}"
                app:items="@{viewModel.projections}"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"></android.support.v7.widget.RecyclerView>

        </android.support.constraint.ConstraintLayout>

        <!-- Ad -->
        <com.kinetoplay.fantasymovieleague.ads.FMLAdView
            android:id="@+id/bottom_ad"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:paddingTop="8dp"
            android:paddingBottom="8dp"
            android:visibility="invisible"
            app:FMLAdSize="@{AdSize.BANNER}"
            app:FMLAdUnit="@{viewModel.footerAd}"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />


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

1 个答案:

答案 0 :(得分:0)

CoordinatorLayout仅仅是FrameLayout。它不尊重Constraints

如果要使用约束,请坚持使用ConstraintsLayout