我有一个水平RecyclerView
在ScrollView
内但没有任何适配器方法正在触发。卧式RecyclerView里面ScrollView不充气 - Android
这是我的片段与ScrollView
:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:background="@color/white"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/selector"
android:layout_width="match_parent"
android:layout_height="100dp"
android:id="@+id/selector"/>
.....
.....
</RelativeLayout>
</ScrollView>
这是我selector.xml布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@color/green">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_kids"
android:layout_width="match_parent"
android:layout_height="100dp" />
</LinearLayout>
这里我设置适配器的RecyclerView
:
selectorAdapter = new selectorAdapter(activity, kids);
rv_items.setLayoutManager(new LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL, false));
rv_items.setAdapter(selectorAdapter);
selectorAdapter.notifyDataSetChanged();
事情是,我已经设置到选择器的绿色背景显示,但没有的适配器方法被触发并且RecyclerView
不会膨胀。 我能做些什么不同?
使用嵌套的滚动视图 –
移动setadapter – Nithinlal
@Nithinlal嘿,这就是它是之前并没有工作,即使随后的setlayoutmanager线之上,所以我试过在下面移动它只是为了尝试。 – Mallika