嵌套的滚动视图中未显示回收站视图

时间:2018-12-10 19:10:14

标签: android layout android-recyclerview scrollview android-nestedscrollview

我在NestedScroll视图中有Recyclerview,它工作正常,但是当上部元素的高度大于嵌套的scrollview时,则不会显示回收器视图。

当topic_lv_layout.xml中的文本很长时,则隐藏回收者视图。但这对于较小的文本来说效果很好。

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
    android:id="@+id/displayTopicMainLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.techxee.adarsh.chatbeta.TopicDisplay"
    android:background="@color/colorBackground2">

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toTopOf="@id/sendCommentLayout"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        android:fillViewport="true">

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

            app:layout_constraintBottom_toTopOf="@+id/sendCommentLayout"
            app:layout_constraintEnd_toEndOf="@+id/sendCommentLayout"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toStartOf="@+id/sendCommentLayout">

            <include
                android:id="@+id/topicLayout"
                layout="@layout/topics_lv_layout"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:elevation="10dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:id="@+id/replyTextTv"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:visibility="gone"
                android:layout_marginBottom="8dp"
                android:background="@android:color/white"
                android:ellipsize="end"
                android:maxEms="15"
                android:maxLines="3"
                android:text="loading..."
                android:textColor="@android:color/darker_gray"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent" />

            <android.support.v4.widget.SwipeRefreshLayout
                android:id="@+id/swipeRefLayoutComment"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                app:layout_constraintBottom_toTopOf="@+id/replyTextTv"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.0"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/topicLayout">

                <FrameLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/commentsRv"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="8dp"
                        android:layout_marginEnd="8dp"
                        android:layout_marginBottom="8dp" />
                </FrameLayout>
            </android.support.v4.widget.SwipeRefreshLayout>


        </android.support.constraint.ConstraintLayout>
    </android.support.v4.widget.NestedScrollView>
    <android.support.constraint.ConstraintLayout
        android:id="@+id/sendCommentLayout"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="4dp"
        android:layout_marginLeft="4dp"
        android:layout_marginEnd="4dp"
        android:layout_marginRight="4dp"
        android:background="@drawable/edittext_rounded"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent">

        <EditText
            android:id="@+id/commentEt"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginLeft="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginRight="8dp"
            android:background="@null"
            android:backgroundTint="@color/colorBackground"
            android:ems="10"
            android:freezesText="true"
            android:hint="Say Something about this..."
            android:inputType="textMultiLine"
            android:maxLines="5"
            android:textSize="14sp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toStartOf="@+id/sendCommentBtn"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <ImageButton
            android:id="@+id/sendCommentBtn"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:background="@drawable/btn_rounded"
            android:src="@drawable/send_btn"
            android:textColor="@color/textColor"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toEndOf="@+id/commentEt" />
    </android.support.constraint.ConstraintLayout>

</android.support.constraint.ConstraintLayout>

topic_lv_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
    android:id="@+id/topicsLvLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="5dp"
    >

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

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

            <include
                android:id="@+id/coverLayout"
                layout="@layout/offensive_topic_layout"
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:elevation="2dp"
                android:translationZ="2dp"
                android:visibility="gone"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <de.hdodenhof.circleimageview.CircleImageView
                android:id="@+id/userImg"
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:layout_marginLeft="16dp"
                android:layout_marginStart="16dp"
                android:layout_marginTop="8dp"
                android:src="@drawable/ic_default_user"
                app:civ_border_color="#FF000000"
                app:civ_border_width="2dp"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:id="@+id/topicOptionsTv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:padding="10dp"
                android:text="&#8942;"
                android:textAppearance="?android:textAppearanceLarge"
                android:textSize="18sp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:id="@+id/usernameTv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="16dp"
                android:layout_marginStart="16dp"
                android:text="Username"
                android:ellipsize="marquee"
                android:textAppearance="@style/TextLabel"
                android:textSize="14sp"
                app:layout_constraintStart_toEndOf="@+id/userImg"
                app:layout_constraintTop_toTopOf="@+id/userImg"
                android:singleLine="true" />

            <TextView
                android:id="@+id/topicTextTv"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginStart="20dp"
                android:layout_marginLeft="20dp"
                android:layout_marginTop="8dp"
                android:layout_marginEnd="8dp"
                android:layout_marginRight="8dp"
                android:gravity="left"
                android:text="Lorem ipsum is something i don't understand and I don't know why it is statndard for garbage or dummy text"
                android:textAppearance="@style/TextLabel"
                android:textSize="16sp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/userImg" />

            <TextView
                android:id="@+id/locationTv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginTop="8dp"
                android:layout_marginBottom="8dp"
                android:text="Somewhere, Planet earth"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/topicTextTv" />

            <!--<ImageButton
        android:id="@+id/likeBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:background="@null"
        app:layout_constraintBottom_toBottomOf="@+id/locationTv"
        app:layout_constraintEnd_toStartOf="@+id/likesTv"
        app:layout_constraintTop_toTopOf="@+id/locationTv"
        app:layout_constraintVertical_bias="0.0"
        app:srcCompat="@drawable/ic_like_topic" />-->
            <com.sackcentury.shinebuttonlib.ShineButton
                android:id="@+id/likeBtn"
                android:layout_width="24dp"
                android:layout_height="24dp"
                android:layout_centerInParent="true"
                android:padding="0dp"
                android:scaleType="fitCenter"
                android:src="@android:color/darker_gray"
                app:allow_random_color="false"
                app:btn_color="@android:color/darker_gray"
                app:btn_fill_color="#ff0000"
                app:layout_constraintBottom_toBottomOf="@+id/locationTv"
                app:layout_constraintEnd_toStartOf="@+id/likesTv"
                app:layout_constraintTop_toTopOf="@+id/locationTv"
                app:layout_constraintVertical_bias="0.0"
                app:siShape="@drawable/ic_like_topic" />

            <!--<ImageButton
        android:id="@+id/dislikeBtn"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:background="#00ffffff"
        android:scaleType="fitCenter"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@+id/dislikesTv"
        app:layout_constraintTop_toTopOf="@+id/likeBtn"
        app:srcCompat="@drawable/ic_dislike" />-->
            <com.sackcentury.shinebuttonlib.ShineButton
                android:id="@+id/dislikeBtn"
                android:layout_width="24dp"
                android:layout_height="24dp"
                android:layout_centerInParent="true"
                android:padding="0dp"
                android:scaleType="fitCenter"
                android:src="@android:color/darker_gray"
                app:allow_random_color="false"
                app:btn_color="@android:color/darker_gray"
                app:btn_fill_color="#2E122D"
                app:layout_constraintBottom_toBottomOf="@+id/likeBtn"
                app:layout_constraintEnd_toStartOf="@+id/dislikesTv"
                app:layout_constraintTop_toTopOf="@+id/likeBtn"
                app:siShape="@drawable/ic_dislike" />

            <TextView
                android:id="@+id/timestampTv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="8dp"
                android:text="right now"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/userImg"
                app:layout_constraintStart_toStartOf="@+id/usernameTv"
                app:layout_constraintTop_toBottomOf="@+id/usernameTv" />

            <TextView
                android:id="@+id/likesTv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="32dp"
                android:layout_marginRight="32dp"
                app:layout_constraintBottom_toBottomOf="@+id/likeBtn"
                app:layout_constraintEnd_toStartOf="@+id/dislikeBtn"
                app:layout_constraintTop_toTopOf="@+id/likeBtn" />

            <TextView
                android:id="@+id/dislikesTv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="8dp"
                android:layout_marginRight="8dp"
                app:layout_constraintBottom_toBottomOf="@+id/dislikeBtn"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toTopOf="@+id/dislikeBtn" />

            <TextView
                android:id="@+id/commentsTv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="8dp"
                app:layout_constraintBottom_toBottomOf="@+id/commentsIv"
                app:layout_constraintEnd_toStartOf="@+id/likeBtn"
                app:layout_constraintTop_toTopOf="@+id/commentsIv"
                app:layout_constraintVertical_bias="0.0"
                android:layout_marginEnd="32dp"
                android:layout_marginRight="32dp"/>

            <ImageView
                android:id="@+id/commentsIv"
                android:layout_width="24dp"
                android:layout_height="24dp"
                android:layout_marginEnd="8dp"
                android:scaleType="fitCenter"
                app:layout_constraintBottom_toBottomOf="@+id/locationTv"
                app:layout_constraintEnd_toStartOf="@+id/commentsTv"
                app:layout_constraintTop_toTopOf="@+id/locationTv"
                app:srcCompat="@drawable/ic_comment" />
        </android.support.constraint.ConstraintLayout>
    </android.support.v7.widget.CardView>
</android.support.constraint.ConstraintLayout>

0 个答案:

没有答案