当recyclelerview在scrollview中时,recycylerview addOnScrollListener未被调用

问题描述 投票:1回答:1

由于使用了Scrollview,rcvLatestPromotions.addOnScrollListener(....)..没有调用。有没有针对这个问题的解决方案?我需要带有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>
android android-recyclerview android-scrollview
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.