【问题标题】:recycylerview addOnScrollListener not called when recyclerview is inside scrollview当 recyclerview 在滚动视图中时,不调用 recyclerview addOnScrollListener
【发布时间】:2019-02-15 15:12:45
【问题描述】:

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>

【问题讨论】:

  • 尝试使用NestedScrollView
  • @VygintasB Insted of ScrollView?
  • 详情参考this答案
  • 感谢您的回复,但很抱歉它不起作用。 @VygintasB
  • 请输入javacode

标签: android android-recyclerview android-scrollview


【解决方案1】:

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

【讨论】:

  • 实际上要求2个recyclerviews 1他的水平和第二个是垂直的应该滚动。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-03-11
  • 1970-01-01
  • 2018-05-12
  • 1970-01-01
  • 2017-12-06
  • 1970-01-01
相关资源
最近更新 更多