Leanback VerticalGridView height: wrap_content - android

I have a VerticalGridView in which i plan to use multiple VerticalGridViews.
Wrap_Content does nothing for a VerticalGridView if its set on it's height, The GridLayoutManager simply ignores it if the view is in a normal view, and it does match_parent it seems. If it is in another Vertical Scrolling view the height is 0.
I cannot override the GridLayoutManager without duplicating the entire leanback library.
How can I achieve wrap_content for it?

setColumnWidth method can be used to achieve it:
gridView.setColumnWidth (ViewGroup.LayoutParams.WRAP_CONTENT)
In my case I extend VerticalGridView and call this method in constructor to make WRAP_CONTENT default behavior

Related

Leanback VerticalGridView height to wrap_content

I am trying to have a leanback VerticalGridView. Inside it I would like to have multmple VerticalGridView. The thing is that wrap_content is ignored by the layoutManager so that the grid height is only the height of one single item insted showing all of them.
I tried to set the layoutManager to a LinearLayoutManager(contenxt, VERTICAL, false) but problem still there. Also I have tried xml obvious options.
Any idea?

how to have recyclerview horizontal imageview share a side like a carousel

I have a recyclerview set up with a linear layout at horizontal where each imageview takes up the full width of the visible recyclerview. I was wondering how to fix this such that the imageview items are next to each other the way you'd see this in a carousel. A copy of what I'm seeing is found below. Thanks!
In your layout item, which you are inflating using the adapter class.. you should define the width of the layout as either wrap_content or a fixed value(for eg: 200dp or something else according to your need). I think you have used match_parent that's why you are facing such an issue.
Feel free to ask if something is unclear.
Looks like the ImageView has been resized based on the layout_height specified and you have a value of wrap_content on the layout_width. You should set the ImageView's attribute android:adjustViewBounds to true.
Reference: https://developer.android.com/reference/android/widget/ImageView#attr_android:adjustViewBounds

Showing full height layout above recyclerview inside scrollview

As the title says. I'm trying to display extremely complex layout with a full height of the viewport but I need it scrollable because under it there is a simple recyclerview with some items. I already thought about putting everything inside a multi type recyclerview adapter but the logic of the upper layout is so complex that I don't think it's possible.
I tried using NestedScrollView with fillViewport set to true but I'm stuck defining dimensions of this upper layout and recyclerview below it. Everything needs to be inside one layout because scrollview can't have more than one child, but when I put everything in a linearlayout and set the upper layout to match_parent it's showing fullscreen until data loads in the recyclerview below it. Then it's treating this upper layout as if it was wrap_content.
I'm out of ideas how can I do something like this. Preferably best would be to have some sort of ViewGroup which would support scrolling and resize the recyclerview below it as we scroll, but I'm not sure how to do it.
you need to set the layout to something like this:
<NestedScrollView - height:match_parent>
<LinearLayout - height:wrap_content>
<LinearLayout(topview) - height:wrap_content/>
<RecyclerView - height:wrap_content />
</LinearLayout>
</NestedScrollView>
And then you programmatically change the height of the "topview" to equal nestedscrollview.

When using RecyclerView in NestedScrollView , how should i set the height of RecyclerView

I have tested that recycler will not in use and RecyclerView will load all data when RecyclerView is wrap_content or match_parent .
You should use NestedScrollView instead of ScrollView when you're trying to scroll another view in your parent layout.
It's very similar to ScrollView and part of the v4 support lib:
https://developer.android.com/reference/android/support/v4/widget/NestedScrollView.html
Use setListViewHeightBasedOnChildren(Listview listview) method to set the height of the ListView inside the ScrollView: it will make your ListView to match parent's height.

How to make child views automatically take a new line to fit the parent width?

First, I want to list tags in a whatever layout. The container's max width is fixed (match_parent), and the tags (TextViews) should no exceed the right border of the container. Meanwhile, the container is a direct child (LinearLayout in my case) of a ScrollView (I emphasize this as I find some solutions using customized onMeasure and onLayout methods extending ViewGroup, but cannot work in ScrollView).
How can I do this?
This could be solved with FlowLayout things, as commented by WaJeEh.

Categories

Resources