Not able to add swipetorefreshlayout inside the collapsetoollbar android

41 Views Asked by At

Hi Folks in my project,

I'm using collapsing toolbar . in that im trying to add the swipe to refresh layout outside of the nested scroll view then whole ui inside the nested is getting hidden..........

please help thanks in advance

below is my code:--

  <?xml version="1.0" encoding="utf-8"?>
 <androidx.coordinatorlayout.widget.CoordinatorLayout 
  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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black_theme">


<com.google.android.material.appbar.AppBarLayout
    android:id="@+id/appBarLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">


    <com.google.android.material.appbar.CollapsingToolbarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:contentScrim="@color/white_opacity"
        app:layout_scrollFlags="scroll|exitUntilCollapsed"
        app:title="@string/app_name">

        <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
            android:id="@+id/swipeRefreshLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

        <androidx.core.widget.NestedScrollView
            android:layout_width="match_parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            android:layout_height="wrap_content">

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/black_theme">

                <LinearLayout
                    android:id="@+id/linear_popular_rt"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:visibility="gone"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent">

                    <TextView
                        android:id="@+id/txtpopularRT"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="@dimen/_10sdp"
                        android:fontFamily="@font/worksans_medium"
                        android:gravity="start"
                        android:text="@string/popular_roundtables"
                        android:textColor="@color/klgrey"
                        android:textSize="@dimen/_14ssp" />

                    <androidx.recyclerview.widget.RecyclerView
                        android:id="@+id/recycler_view_horizontal"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_marginStart="@dimen/_10sdp"
                        android:orientation="horizontal" />

                    <include
                        android:id="@+id/layout_sticky_view"
                        layout="@layout/item_sticky_header_townhall_view" />
                </LinearLayout>

                <androidx.appcompat.widget.AppCompatTextView
                    android:id="@+id/tvBreakingNews"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="@dimen/_10sdp"
                    android:layout_marginTop="@dimen/_5sdp"
                    android:fontFamily="@font/worksans_regular"
                    android:text="@string/breaking_news"
                    android:textColor="@color/solitude"
                    android:textSize="@dimen/_13ssp"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@id/linear_popular_rt" />

                <androidx.appcompat.widget.AppCompatTextView
                    android:id="@+id/tvSeeAll"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="@dimen/_10sdp"
                    android:fontFamily="@font/worksans_regular"
                    android:text="@string/see_all"
                    android:textColor="@color/solitude"
                    android:textSize="@dimen/_13ssp"
                    android:visibility="gone"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />


                <androidx.viewpager2.widget.ViewPager2
                    android:id="@+id/vpBreakingNews"
                    android:layout_width="0dp"
                    android:layout_height="0dp"
                    android:layout_marginTop="@dimen/_5sdp"
                    android:orientation="horizontal"
                    android:visibility="visible"
                    app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
                    app:layout_constraintDimensionRatio="h,16:9"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@id/tvBreakingNews" />

                <LinearLayout
                    android:id="@+id/bnIndicator"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/vpBreakingNews"
                    android:layout_marginTop="@dimen/_3sdp"
                    android:gravity="center_horizontal"
                    android:orientation="horizontal"
                    app:layout_constraintEnd_toEndOf="@id/vpBreakingNews"
                    app:layout_constraintStart_toStartOf="@id/vpBreakingNews"
                    app:layout_constraintTop_toBottomOf="@id/vpBreakingNews" />
            </androidx.constraintlayout.widget.ConstraintLayout>

        </androidx.core.widget.NestedScrollView>
        </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:layout_gravity="top"
            android:background="@color/black_theme"
            android:visibility="gone"
            app:contentInsetStart="0dp"
            app:layout_collapseMode="pin"
            app:titleTextColor="@color/black"
            tools:ignore="MissingPrefix">

            <include
                android:id="@+id/layout_sticky_view_outer"
                layout="@layout/item_sticky_header_townhall_view" />
        </androidx.appcompat.widget.Toolbar>

    </com.google.android.material.appbar.CollapsingToolbarLayout>


</com.google.android.material.appbar.AppBarLayout>


<androidx.constraintlayout.widget.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <androidx.appcompat.widget.AppCompatTextView
        android:id="@+id/tvForYouNews"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/_10sdp"
        android:layout_marginTop="@dimen/_7sdp"
        android:fontFamily="@font/worksans_regular"
        android:text="@string/for_you"
        android:textColor="@color/solitude"
        android:textSize="@dimen/_13ssp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rvForYou"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/_5sdp"
        android:orientation="vertical"
        android:paddingBottom="@dimen/_20sdp"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        app:layout_constraintTop_toBottomOf="@id/tvForYouNews" />

</androidx.constraintlayout.widget.ConstraintLayout>



<TextView
    android:id="@+id/tvNewPost"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|center_horizontal"
    android:layout_margin="15dp"
    android:background="@drawable/rounded_corner_noti"
    android:fontFamily="@font/worksans_regular"
    android:padding="10dp"
    android:visibility="gone" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>

0

There are 0 best solutions below