I have requirement where i need to have many horizontal RecyclerView It will have interface similar to Google PlayStore. Now the problem is If i add ScrollView in my layout and run app then it shows nothing on screen.
When i remove it show RecyclerView
This is XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/featured"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10sp"
android:background="#ECEFF1" />
<android.support.v7.widget.RecyclerView
android:id="#+id/latest"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10sp" />
<android.support.v7.widget.RecyclerView
android:id="#+id/startup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10sp" />
</LinearLayout>
</ScrollView>
</LinearLayout
How should i solve this problem. I want to add ScrollView to activity which will have 9 to 10 horizontal RecyclerView
Set the height of the Recyclerviews to an actual dp value
Related
This is the code :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/grey_f2"
android:fillViewport="true"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/rv_achievement_badges"
android:focusableInTouchMode="false"
/>
<LinearLayout
android:background="#color/white"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="25dp"
>
<com.sharesmile.share.views.LBTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hall_of_fame"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:textColor="#color/black_64"
android:textSize="20sp"
/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/rv_hall_of_fame"
android:focusableInTouchMode="false"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
The issue is rv_hall_of_fame does not show all items.
tried nestedsrollview, viewport, canScrollVertically and setNestedScrollingEnabled and nothing is working. Can you let me know.
You should remove the second recyclerview from the linearlayout. Maybe that is the reason you can't see all items.
EDIT:
I think you should use NestedScrollView. I had the same problem in one of my projects and I changed my code to below which solved my problem.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/grey_f2"
android:fillViewport="true"
android:focusableInTouchMode="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/rv_achievement_badges"/>
<com.sharesmile.share.views.LBTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/hall_of_fame"
android:layout_marginTop="10dp"
android:textColor="#color/black_64"
android:textSize="20sp"
android:background="#color/white"
android:paddingLeft="25dp"
android:paddingTop="36dp"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/rv_hall_of_fame"
android:background="#color/white"
android:layout_marginBottom="7dp"
android:paddingBottom="30dp"
android:paddingTop="30dp"
android:paddingLeft="25dp"
android:paddingRight="25dp"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
It's not wise to put a RecyclerView or a ListView inside a ScrollView. Android doesn't know how to handle user events. In addition, in your case, you have two RecyclerView inside that root ScrollView... It's madness both for the Android UI framework and for the user.
A solution could be to only use one RecyclerView that handles the scroll user action, and an Adapter that knows how to render everything you use: achievements badges, the hall of fame label, and the players. So, you'll only need one RecyclerView, and it will work like a charm.
I want to have a "fixed_space" at the top of screen and a "scrollview" at the bottom of the screen which should be below fixed_space. The rest of the screen is a container "rest_space".
Unfortunately my scrollview has a shorter height(by 100dp which fixed_space has) ,if content is too big/scrollable.
I tried to achieve same with ConstraintLayout and RelativeLayout, but I have got same result.
Any ideas why scrollview has 100dp shorter height, as it should be?
EDIT: Scrollview should take as much space as she needs.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:id="#+id/fixed_space"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#android:color/holo_red_dark" />
<View
android:id="#+id/rest_space"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#android:color/black" />
<ScrollView
android:id="#+id/scrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/holo_green_dark"
android:fillViewport="true">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="START OF SCROLLVIEW \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nMIDDLE OF SCROLLVIEW \n\n\n\n\n\n\n\n\n\n\n\nEND OF SCROLLVIEW" />
</ScrollView>
</LinearLayout>
Try this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:id="#+id/fixed_space"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#android:color/holo_red_dark" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="#+id/rest_space"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/scrollview"
android:background="#android:color/black" />
<ScrollView
android:id="#+id/scrollview"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/holo_green_dark"
android:fillViewport="true">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="START OF SCROLLVIEW \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nMIDDLE OF SCROLLVIEW \n\n\n\n\n\n\n\n\n\n\n\nEND OF SCROLLVIEW" />
</ScrollView>
</RelativeLayout>
</LinearLayout>
Ok, I think this should solve your probem:
First, I started by using RelativeLayout. I did it in order to get the fixed_space aligned to the top and the scrollview aligned to the bottom.
Then I changed the View for a LinearLayout and put a TextView within it so I could use wrap_content and this is the tricky part:
When you use ScrollView with wrap_content and a View with the weight stuff, Android can't make the calculations it needs to get the screen drawed because there is no reference. When I put the TextView with wrap_content itself that gives the reference because Android know the size of the text.
You don't have to use the TextView but you will need anything that gives Android that reference.
In this case, the scrollview is going to be stretched, not the LinearLayout. If you want the second to get strached, then I'm afraid you are going to need to set a fixed height to your scrollview.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:id="#+id/fixed_space"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:background="#android:color/holo_red_dark" />
<LinearLayout
android:id="#+id/rest_space"
android:layout_below="#+id/fixed_space"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/black">
<TextView
android:text="Test"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<ScrollView
android:id="#+id/scrollview"
android:layout_below="#id/rest_space"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/holo_green_dark"
android:layout_alignParentBottom="true">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="START OF SCROLLVIEW \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nMIDDLE OF SCROLLVIEW \n\n\n\n\n\n\n\n\n\n\n\nEND OF SCROLLVIEW" />
</ScrollView>
</RelativeLayout>
I am building a daily schedule like for students. This schedule is in a fragment. I need a sticky header with seven day labels and then the items need to scroll underneath, all at once. In addition I need the entire view to scroll horizontally.
Currently I have a HorizontalScrollView, some nested LinearLayouts, and a NestedScrollView. There are 7 RecyclerViews that are children of the NestedScrollView, one for each day of the week. This is so that I can call setNestedScrollingEnabled(false) on each RecyclerView so they scroll together. Currently the result is that the NestedScrollView clips the RecyclerViews to 1 item and no scrolling is possible. If I remove the NestedScrollView The RecyclerViews all scroll individually which is not what I want.
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
android:elevation="4dp" />
<FrameLayout
android:layout_below="#id/toolbar"
android:id="#+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
fragment_schedule.xml
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ProgressBar
android:id="#+id/loading"
android:layout_width="74dp"
android:layout_height="74dp"
android:visibility="gone"
android:layout_gravity="center"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
...7 ImageViews representing days of week...
</LinearLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true"
android:layout_marginTop="8dp">
<android.support.v7.widget.RecyclerView
android:id="#+id/sunday_list"
android:layout_width="84dp"
android:layout_height="wrap_content"
tools:background="#color/accent_gold"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/monday_list"
android:layout_width="84dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
tools:background="#color/accent_gold"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/tuesday_list"
android:layout_width="84dp"
android:layout_marginLeft="8dp"
android:layout_height="wrap_content"
tools:background="#color/accent_gold"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/wednesday_list"
android:layout_width="84dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
tools:background="#color/accent_gold"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/thursday_list"
android:layout_width="84dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
tools:background="#color/accent_gold"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/friday_list"
android:layout_width="84dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
tools:background="#color/accent_gold"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/saturday_list"
android:layout_width="84dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
tools:background="#color/accent_gold"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
</HorizontalScrollView>
The only thing of note in the fragment class is that I call setNestedScrolledEnabled(false) after populating and attaching all of the adapters.
Any insight is greatly appreciated!
The solution in this case is that I was thinking about the requirements too rigidly. I changed my layout to consists of a The header linear layout, a scrollview, and a horizontal recycler view, with each day being an item. In the adapter the item layout is simply a LinearLayout that I programmatically add the class views to(as there is a finite number of classes per day). Scrolling works in both directions. I will retitle the question so hopefully someone can find this working towards similar requirements.
Fragment xml
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ProgressBar
android:id="#+id/loading"
android:layout_width="74dp"
android:layout_height="74dp"
android:visibility="gone"
android:layout_gravity="center"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
...Image Views Representing Days of Week...
</LinearLayout>
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="#+id/day_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</ScrollView>
</LinearLayout>
</HorizontalScrollView>
RecyclerViewItem.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="84dp"
android:layout_height="match_parent"
android:id="#+id/item_schedule_layout"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_marginLeft="0dp">
</LinearLayout>
Then programmatically add views to the LinearLayout. My views for each class were complex so I created a custom view based on the layout I needed for each class and then was able to just define a new instance in a for loop and add it to the LinearLayout.
I have put two listview in scrollview but i have a problem, when i put item in the first listview the second listview will be scrollable. I want that the whole area will be scrollable and not scrollview, How i do? the first scrollview is listViewEventiAggiunti the second listViewEventi.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:fillViewport="true">
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:id="#+id/activity_lista__eventi"
android:paddingBottom="#dimen/padBottom"
android:paddingLeft="#dimen/padLeft"
android:paddingRight="#dimen/padRight"
android:paddingTop="#dimen/padTop"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:context="com.example.fra87.eudroid.activity_class.Lista_Eventi">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="vertical">
<SearchView
android:layout_width="match_parent"
android:layout_height="50dp"
android:queryHint="Evento"
android:id="#+id/cercaEvento"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:id="#+id/linearLayoutEventi">
<EditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:hint="Nome Evento"
android:textSize="22dip"
android:id="#+id/editText_nome_evento_composto"/>
<ListView
android:id="#+id/listViewEventiAggiunti"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp" />
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:id="#+id/separatore_liste"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="#android:color/darker_gray"/>
<ListView
android:id="#+id/listViewEventi"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/cercaEvento"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
I want scroll entire area, i don't want scroll on listview, when i put item in listview the area increases and i scroll entire area is possible?
Ok. Since your minimum SDK version is 16, you have 2 solution for your problem.
First is use this library:
https://github.com/PaoloRotolo/ExpandableHeightListView
This library makes you able to expand your ListViews to full height and then only your ScrollView will be scrollable.
Second solution is to use NestedScrollView instead of ScrollView and then use RecyclerView instead of ListView. Then you should only disable nestedScrolling for your RecyclerView.
Both solutions will give you your desire behavior.
You can use multiple type item for listview and simplified your layout to become like this
<?xml version="1.0" encoding="utf-8"?><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_lista__eventi"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="#dimen/padBottom"
android:paddingLeft="#dimen/padLeft"
android:paddingRight="#dimen/padRight"
android:paddingTop="#dimen/padTop"
tools:context="com.example.fra87.eudroid.activity_class.Lista_Eventi"
>
<SearchView
android:id="#+id/cercaEvento"
android:layout_width="match_parent"
android:layout_height="50dp"
android:queryHint="Evento"
/>
<EditText
android:id="#+id/editText_nome_evento_composto"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="#+id/cercaEvento"
android:hint="Nome Evento"
android:textSize="22dip"
/>
<View
android:id="#+id/separatore_liste"
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_below="#+id/editText_nome_evento_composto"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:background="#android:color/darker_gray"
/>
<ListView
android:id="#+id/listViewEventi"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/separatore_liste"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
/>
</RelativeLayout>
I am developing an Android app. In my app, I want to use two RecyclerViews in one layout. I used LinearLayout to wrap up RecyclerViews because of this Stack Overflow question (Two RecyclerViews under each other in one layout).
As you can see the answer says, to use LinearLayout and set RecyclerViews height to wrap_content. I followed it. But when I run only one RecyclerView is appear and one is missing.
This is the screenshot:
As you can see, only on RecyclerView is appeared.
This is my XML layout:
<LinearLayout
android:orientation="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:scrollbars="vertical"
android:id="#+id/ai_rc_reviews"
android:layout_width="match_parent"
android:layout_height="wrap_content"></android.support.v7.widget.RecyclerView>
<android.support.v7.widget.RecyclerView
android:scrollbars="vertical"
android:id="#+id/ai_rc_reviews_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"></android.support.v7.widget.RecyclerView>
</LinearLayout>
I tried this as well. Nothing appears on screen:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<android.support.v7.widget.RecyclerView
android:id="#+id/ai_rc_reviews"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:background="#color/white"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/ai_rc_reviews_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"/>
</LinearLayout>
</ScrollView>
How can I fix my code to use two RecyclerViews in single layout. Is there any better way to do it?
Try using the layout_weight property instead of wrap_content. Give both RecyclerViews same weight and change height to 0dp.
<LinearLayout
android:orientation="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:scrollbars="vertical"
android:id="#+id/ai_rc_reviews"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dp">
</android.support.v7.widget.RecyclerView>
<android.support.v7.widget.RecyclerView
android:scrollbars="vertical"
android:id="#+id/ai_rc_reviews_2"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dp">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
Generally it's not a good idea to have two scroll containers one inside the other if they scroll along the same axis. That behavior will most likely cause confusion with the user. Instead, if you are 100% sure that you need to have two scrolling containers vertically stacked - and please try not to do it if not 100% necessary, you should use fixed heights for each container as it will positively impact overall performance of the created layout.
<ScrollView `xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:scrollbars="none"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<!-- Usual Size -->
<LinearLayout
android:id="#+id/usualSize_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/color_f5f5f5"
android:layout_marginLeft="#dimen/common_10"
android:layout_marginTop="#dimen/common_10"
android:orientation="vertical"
>
<TextView
android:id="#+id/usualSize_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="size"
android:textSize="#dimen/font_15"
android:textColor="#color/color_999999"
android:layout_marginTop="#dimen/common_16"
android:layout_marginBottom="#dimen/common_10"
/>
<android.support.v7.widget.RecyclerView
android:id="#+id/usualSize_group"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="#dimen/list_height"
/>
</LinearLayout>
<!-- MarkImage -->
<LinearLayout
android:id="#+id/mark_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/color_f5f5f5"
android:layout_marginLeft="#dimen/common_10"
android:layout_marginTop="#dimen/common_10"
android:orientation="vertical"
>
<TextView
android:id="#+id/mark_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="mark"
android:textColor="#color/color_999999"
android:textSize="#dimen/font_15"
android:layout_marginTop="#dimen/common_16"
android:layout_marginBottom="#dimen/common_10"
/>`
<android.support.v7.widget.RecyclerView
android:id="#+id/mark_group"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="#dimen/list_height" />
</LinearLayout>
</LinearLayout>
</ScrollView>
Here we should think twice the WRAP_CONTENY ,so we should in the file:build.gradle.
Please update version of a library in gradle file :
compile 'com.android.support:recyclerview-v7:23.2.1'
and higher version.please check your version.
How do I make WRAP_CONTENT work on a RecyclerView
<!-- Usual Size -->
<LinearLayout
android:id="#+id/usualSize_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/color_f5f5f5"
android:layout_marginLeft="#dimen/common_10"
android:layout_marginTop="#dimen/common_10"
android:orientation="vertical">
<TextView
android:id="#+id/usualSize_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="size"
android:textSize="#dimen/font_15"
android:textColor="#color/color_999999"
android:layout_marginTop="#dimen/common_16"
android:layout_marginBottom="#dimen/common_10"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/usualSize_group"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="#dimen/list_height"/>
</LinearLayout>
<!-- MarkImage -->
<LinearLayout
android:id="#+id/mark_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/color_f5f5f5"
android:layout_marginLeft="#dimen/common_10"
android:layout_marginTop="#dimen/common_10"
android:orientation="vertical">
<TextView
android:id="#+id/mark_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="mark"
android:textColor="#color/color_999999"
android:textSize="#dimen/font_15"
android:layout_marginTop="#dimen/common_16"
android:layout_marginBottom="#dimen/common_10"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/mark_group"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="#dimen/list_height"/>
</LinearLayout>
</LinearLayout>
Here we should think twice the WRAP_CONTENY, so we should in the file:build.gradle.
Please update version of a library in gradle file :
compile com.android.support:recyclerview-v7:23.2.1
and higher version. please check your version.
How do I make WRAP_CONTENT work on a RecyclerView
Just in case someone has two RecyclerViews and other views inside one Srcollview,
if you have problem that the first recyclerview won't scroll up or second one part missing,
if you used LinearLayout to contain these RecyclerViews , try to use relativeLayout instead, which solved my problem.