I have a RecycleView set to horizontal. Now I would like the height to match the height of the element in the view. I do not know the height in advance.
I currently have this:
The main fragment:
<RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.v7.widget.RecyclerView android:layout_width="match_parent" android:layout_height="match_parent" android:scrollbars="horizontal" android:layout_marginLeft="1dp" android:layout_marginRight="1dp" android:layout_marginTop="1dp" android:layout_gravity="top" android:id="@+id/my_listview"/> </RelativeLayout> <android.support.v4.view.ViewPager android:id="@+id/viewpager" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" />
Picture
<ImageView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/banner_image" android:adjustViewBounds="true" android:scaleType="fitXY" android:background="@color/dark_gray" />
but it always takes up the whole screen. therefore, I have many gaps between them. Is there a way I could use wrap_content for recycleview elements?
It looks like this: 
Currently, I have placed 2 banners, the top one with a large space and a small image - one that has a recyclerview. The one below is just an image placed on the image (this is what it should look like, but I want it with recyclerview so that I can scroll through the banners if I have several)
source share