带CoordinatorLayout的Recylerview位置不正确

时间:2019-02-08 06:07:33

标签: android xml android-coordinatorlayout

我正在recylerview上为cordinatorlayout工作。我需要一个底部的聊天栏,因此我以RelativeLayout作为父视图,以cordinatorlayout作为子视图。在cordinatorlayout内部,我采用了一个RelativeLayout,在其中我采用了RecylerviewTextView,但是它们采用了bottom bar的间距。由于我无法获得居中的文本位于image中的中心位置 。 我在xml文件

中使用了以下代码
<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout 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="wrap_content"
    android:fitsSystemWindows="true">

    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/clCompleteLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/inBottomChatWidgets"
        android:fitsSystemWindows="true">


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

            <android.support.design.widget.CollapsingToolbarLayout
                android:id="@+id/collapsing_toolbar"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                app:layout_scrollFlags="scroll|exitUntilCollapsed">

                <FrameLayout
                    android:layout_width="match_parent"
                    android:layout_height="200dp">

                    <ImageView
                        android:id="@+id/image"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:contentDescription="@string/app_name"
                        android:fitsSystemWindows="true"
                        android:scaleType="centerCrop"
                        android:src="@drawable/app_icon"
                        app:layout_collapseMode="parallax" />

                    <ImageView
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:background="@color/black_transparent"
                        android:contentDescription="@string/app_name"
                        android:fitsSystemWindows="true"
                        android:scaleType="centerCrop"
                        app:layout_collapseMode="parallax" />

                    <include
                        android:id="@+id/inToolbar"
                        layout="@layout/include_team_detals_and_chat_header"
                        android:visibility="visible" />

                </FrameLayout>


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

            <android.support.v7.widget.Toolbar
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom">

                <include
                    android:id="@+id/rl_sagments"
                    layout="@layout/include_segment_controller"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="bottom"
                    android:visibility="visible" />

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


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

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/tw__solid_white"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

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

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:text="Chat not started yet" />

        </RelativeLayout>


        <!-- Add to cart button -->


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


    <include
        android:id="@+id/inBottomChatWidgets"
        layout="@layout/include_team_members_chat"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" />


</RelativeLayout>

请让我知道我做错了什么。

通过编程,我将可见性更改为

 rvTeamChat.visibility = View.GONE

0 个答案:

没有答案