android - 当 recyclerview 在 scrollview 内时不调用 recycylerview addOnScrollListener

标签 android android-recyclerview android-scrollview

rcvLatestPromotions.addOnScrollListener(....).. 因为使用了 Scrollview 而没有调用。这个问题有什么解决办法吗?我需要带有 addOnScrollListenerworking 的 recyclerViews,以及它的父 ScrollView。

请帮我解决这个问题,我将不胜感激。感谢期待。

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@+id/flContainer"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ebebed"
xmlns:app="http://schemas.android.com/apk/res-auto">

    <ScrollView
        android:id="@+id/svContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        android:fitsSystemWindows="true"
        tools:context=".activities.MainNavigationActivity"
        tools:showIn="@layout/app_bar_main_navigation">


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:orientation="vertical"
                android:visibility="visible">

                <TextView
                    android:id="@+id/txtNearPromotions"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="2dp"
                    android:background="@color/colorWhite"
                    android:text="Near by"
                    android:textColor="@color/colorBlack"
                    android:textSize="18sp"/>

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/rcvNearPromotions"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@color/colorRecyclerViewBg"
                    android:nestedScrollingEnabled="false"
                    android:orientation="horizontal"/>

                <TextView
                    android:id="@+id/txtLatestPromotions"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="2dp"
                    android:background="@color/colorWhite"
                    android:text="Latest"
                    android:textColor="@color/colorBlack"
                    android:textSize="18sp"/>

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/rcvLatestPromotions"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@color/colorRecyclerViewBg"
              app:layout_behavior="@string/appbar_scrolling_view_behavior"
                    android:nestedScrollingEnabled="false"/>
            </LinearLayout>
    </ScrollView>

    <com.dev.promotionapp.utils.VerticalTextView
        android:id="@+id/txtOpenDrawer"
        style="@style/verticalTextStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_gravity="center_vertical"
        android:background="@color/colorPrimaryDark"
        android:rotation="180"
        android:text="   Lahore   "
        android:textColor="@color/colorWhite"
        android:textSize="18sp"/>
</FrameLayout>

最佳答案

在可滚动布局中使用可 ScrollView 不是一个好的选择,我认为这是不可能的,你做不到,如果你需要在 ScrollView 中使用 recyclerView/listview 这是一个很好的库。 https://github.com/paolorotolo/ExpandableHeightListView

关于android - 当 recyclerview 在 scrollview 内时不调用 recycylerview addOnScrollListener,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54712166/

相关文章:

php - JSON 编码返回相同类型

android - 无法在 Eclipse IDE 上获取项目的系统库

android - 为什么 RecylerView.notifyDataSetChanged() 在添加导航组件后停止工作?

android - java.lang.IllegalArgumentException : Scrapped or attached views may not be recycled. isScrap:false isAttached:true 向下滚动时

android-recyclerview - L 中的 RecyclerView onItemClick 效果

java - Android : java. lang.NullPointerException/合并视频

android - 如何自动更新应用程序;安卓

android - 加载数据后如何防止 ScrollView 滚动到 WebView ?

Android ListView 无法正确缩放

Android WebView跳到底部