Skip to main content

RecyclerViewsRecyclerViews are fine to put in ScrollViewsScrollViews so long as they aren't scrolling themselves. In this case, it makes sense to make it a fixed height.

The proper solution is to use wrap_content on the RecyclerViewRecyclerView height and then implement a custom LinearLayoutManagerLinearLayoutManager that can properly handle the wrapping.

Copy this LinearLayoutManager into your project: https://github.com/serso/android-linear-layout-manager/blob/master/lib/src/main/java/org/solovyev/android/views/llm/LinearLayoutManager.javalink

Then wrap the RecyclerViewRecyclerView:

<android.support.v7.widget.RecyclerView android:layout_width="match_parent" android:layout_height="wrap_content"/> 

And set it up like so:

 RecyclerView list = (RecyclerView)findViewById(R.id.list);  list.setHasFixedSize(true);  list.setLayoutManager(new com.example.myapp.LinearLayoutManager(list.getContext()));  list.setAdapter(new MyViewAdapter(data)); 

Edit: This can cause complications with scrolling because the RecyclerViewRecyclerView can steal the ScrollView'sScrollView's touch events. My solution was just to ditch the RecyclerViewRecyclerView in all and go with a LinearLayoutLinearLayout, programmatically inflate subviews, and add them to the layout.

RecyclerViews are fine to put in ScrollViews so long as they aren't scrolling themselves. In this case, it makes sense to make it a fixed height.

The proper solution is to use wrap_content on the RecyclerView height and then implement a custom LinearLayoutManager that can properly handle the wrapping.

Copy this LinearLayoutManager into your project: https://github.com/serso/android-linear-layout-manager/blob/master/lib/src/main/java/org/solovyev/android/views/llm/LinearLayoutManager.java

Then wrap the RecyclerView:

<android.support.v7.widget.RecyclerView android:layout_width="match_parent" android:layout_height="wrap_content"/> 

And set it up like so:

 RecyclerView list = (RecyclerView)findViewById(R.id.list);  list.setHasFixedSize(true);  list.setLayoutManager(new com.example.myapp.LinearLayoutManager(list.getContext()));  list.setAdapter(new MyViewAdapter(data)); 

Edit: This can cause complications with scrolling because the RecyclerView can steal the ScrollView's touch events. My solution was just to ditch the RecyclerView in all and go with a LinearLayout, programmatically inflate subviews, and add them to the layout.

RecyclerViews are fine to put in ScrollViews so long as they aren't scrolling themselves. In this case, it makes sense to make it a fixed height.

The proper solution is to use wrap_content on the RecyclerView height and then implement a custom LinearLayoutManager that can properly handle the wrapping.

Copy this LinearLayoutManager into your project: link

Then wrap the RecyclerView:

<android.support.v7.widget.RecyclerView android:layout_width="match_parent" android:layout_height="wrap_content"/> 

And set it up like so:

RecyclerView list = (RecyclerView)findViewById(R.id.list); list.setHasFixedSize(true); list.setLayoutManager(new com.example.myapp.LinearLayoutManager(list.getContext())); list.setAdapter(new MyViewAdapter(data)); 

Edit: This can cause complications with scrolling because the RecyclerView can steal the ScrollView's touch events. My solution was just to ditch the RecyclerView in all and go with a LinearLayout, programmatically inflate subviews, and add them to the layout.

added 264 characters in body
Source Link
jcady
  • 4k
  • 2
  • 25
  • 22

RecyclerViews are fine to put in ScrollViews so long as they aren't scrolling themselves. In this case, it makes sense to make it a fixed height.

The proper solution is to use wrap_content on the RecyclerView height and then implement a custom LinearLayoutManager that can properly handle the wrapping.

Copy this LinearLayoutManager into your project: https://github.com/serso/android-linear-layout-manager/blob/master/lib/src/main/java/org/solovyev/android/views/llm/LinearLayoutManager.java

Then wrap the RecyclerView:

<android.support.v7.widget.RecyclerView android:layout_width="match_parent" android:layout_height="wrap_content"/> 

And set it up like so:

 RecyclerView list = (RecyclerView)findViewById(R.id.list); list.setHasFixedSize(true); list.setLayoutManager(new com.example.myapp.LinearLayoutManager(list.getContext())); list.setAdapter(new MyViewAdapter(data)); 

Edit: This can cause complications with scrolling because the RecyclerView can steal the ScrollView's touch events. My solution was just to ditch the RecyclerView in all and go with a LinearLayout, programmatically inflate subviews, and add them to the layout.

RecyclerViews are fine to put in ScrollViews so long as they aren't scrolling themselves. In this case, it makes sense to make it a fixed height.

The proper solution is to use wrap_content on the RecyclerView height and then implement a custom LinearLayoutManager that can properly handle the wrapping.

Copy this LinearLayoutManager into your project: https://github.com/serso/android-linear-layout-manager/blob/master/lib/src/main/java/org/solovyev/android/views/llm/LinearLayoutManager.java

Then wrap the RecyclerView:

<android.support.v7.widget.RecyclerView android:layout_width="match_parent" android:layout_height="wrap_content"/> 

And set it up like so:

 RecyclerView list = (RecyclerView)findViewById(R.id.list); list.setHasFixedSize(true); list.setLayoutManager(new com.example.myapp.LinearLayoutManager(list.getContext())); list.setAdapter(new MyViewAdapter(data)); 

RecyclerViews are fine to put in ScrollViews so long as they aren't scrolling themselves. In this case, it makes sense to make it a fixed height.

The proper solution is to use wrap_content on the RecyclerView height and then implement a custom LinearLayoutManager that can properly handle the wrapping.

Copy this LinearLayoutManager into your project: https://github.com/serso/android-linear-layout-manager/blob/master/lib/src/main/java/org/solovyev/android/views/llm/LinearLayoutManager.java

Then wrap the RecyclerView:

<android.support.v7.widget.RecyclerView android:layout_width="match_parent" android:layout_height="wrap_content"/> 

And set it up like so:

 RecyclerView list = (RecyclerView)findViewById(R.id.list); list.setHasFixedSize(true); list.setLayoutManager(new com.example.myapp.LinearLayoutManager(list.getContext())); list.setAdapter(new MyViewAdapter(data)); 

Edit: This can cause complications with scrolling because the RecyclerView can steal the ScrollView's touch events. My solution was just to ditch the RecyclerView in all and go with a LinearLayout, programmatically inflate subviews, and add them to the layout.

Source Link
jcady
  • 4k
  • 2
  • 25
  • 22

RecyclerViews are fine to put in ScrollViews so long as they aren't scrolling themselves. In this case, it makes sense to make it a fixed height.

The proper solution is to use wrap_content on the RecyclerView height and then implement a custom LinearLayoutManager that can properly handle the wrapping.

Copy this LinearLayoutManager into your project: https://github.com/serso/android-linear-layout-manager/blob/master/lib/src/main/java/org/solovyev/android/views/llm/LinearLayoutManager.java

Then wrap the RecyclerView:

<android.support.v7.widget.RecyclerView android:layout_width="match_parent" android:layout_height="wrap_content"/> 

And set it up like so:

 RecyclerView list = (RecyclerView)findViewById(R.id.list); list.setHasFixedSize(true); list.setLayoutManager(new com.example.myapp.LinearLayoutManager(list.getContext())); list.setAdapter(new MyViewAdapter(data));