簡體   English   中英

當recyclerview在scrollview內部時,不會調用recycylerview addOnScrollListener

[英]recycylerview addOnScrollListener not called when recyclerview is inside scrollview

由於使用了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>

在可滾動布局中使用可滾動視圖不是一個好選擇,我認為這是不可能的,您無法做到這一點,如果您需要在ScrollView中使用recyclerView / listview,那么這是一個很好的庫。 https://github.com/paolorotolo/ExpandableHeightListView

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM