On my Android app, I am trying to create a list of tags on top of a recyclerview. the goal is to have a kind of filtering feature. The screen will be composed of 2 recyclerviews.
The first one contains buttons with name inside which will be used later as a filter. You can click on one or more buttons and update the list of videos displayed in the second recyclerview.
The second recyclerview is just a list of items (in my case video) displayed vertically.
The system works fine, but I am having trouble to have the look I expect for the part where the buttons have to be displayed. I tried to have them order horizontally, and it's show them vertically. I tried using Grid, but Grid is creating a grid with fixed column width when in my case the column width has to adjusted to the button size. The width of the button is just depending on the length of the text.
I am using the code below, but it's not doing with I need:
binding.tagLayout.apply {
layoutManager = LinearLayoutManager(activity)
tagAdapter = TagAdapter(context, tagList).apply {
adapter = this
}
}
This is just getting me a vertical list. When I try to get something, as below:
The image above is not the design, but it gives an idea of what I expect. I just want to create a list, where the item are displayed horizontally and when reaching the end of the screen, we go to the next line. I could have 2, 3,... buttons on one line, the number of items displayed in one line, is based on the size of each item.
Any idea ?
Related
I have a CustomView that is a LinearLayout where it contains
TextView
RecyclerView
TheRecyclerViewItem
That's because I need to do something like this :
The first picture it works fine, but when trying to populate the list with more items, it gets the size of the Item and I'd like to make it a bit smaller so I can see in the screen the second item, otherwise the list only have visible one item at once, and that's normal because I'm using the same view for the item of recycler view than my first image, but I didn't want to duplicate layout, if that's the only solution I'll do it, but I'm trying to figure it out a "better" solution than duplicating and make it a different width.
I have a listView that is populate via a RSS feed. The height of each item on the ListView can vary depending on the length on the content. Is there a way to only add enough items to the listView to fill the screen (the listView has a fixed height).
For example if each item only has one line of text I can fit 7, but if they have two lines of text I can only fit 5. I want to be able to programmatically decide when to stop adding items. I don't want the ListView to have to scroll.
EDIT
Let me rephrase. I don't want to just solve it but scrolling down. There may at some point in the development be content that gets added below the screen and requires scrolling but even in that case I don't want half an item showing at the bottom. Basically I don't want broken/half items showing at the bottom, if it's on the screen it should be the whole item that is showing. If not it should be below the bottom of screen.
Try using a normal Linear Layout and when adding the inflated row, override the onMeasure to know if it fits on the screen.
Sory I can't describe a right title for my question,
I want to create listview something like this
In top of list view on screen look like
and when user scroll the list in screen will be like this
and in end of list is
I have 3 picture for top list, middle and bottom list.
I already try to add header and footer for top image and bottom image but looks like the picture is inside the list view
I try to create vertical linear layout and put picture top,middle and bottom in sequence but still not get result that i expected
Do anyone have a suggestion for listview like this
Don't set your frame background for entire listview or its parent. Instead first slice your frame background into three parts, (i) topframe (ii) middleframe (iii) bottomframe. Now create a custom listview and set background for each and every list rows.
In order to achieve your design, you need to find the first and last item of list and set topframe for first row and bottomframe for last row , all the other rows background should be middleframe.
I have a list of categories. I'd like to add them in a horizontal scroll type view. But inturn i also want that the list contains only image and text of that category. And when i slide, it should directly come to an object of the list, it should not lie somewhere in the middle.
One object will almost cover the
How should i do implement that?
I would like to have last item of the listView aligned on the bottom.
In case there are 1 to several items on the list, there should be an empty space between last item and second to last item.
In case there are many items (they do not fit in the list, scroll is shown), the list should behave normally.
I tried to make it so that when list consists of some small hardcoded number (6) of items (or less), last item is separate view aligned to the bottom of the parent of the listView. When there are more items, I set visibility of this view to GONE and added same view to the listView. It was working fine, but not for all devices. Some fit 6 items, but others fit 7.
Is there any way to align last item to the bottom of the listView (so the listView has always the same height as its parent)?
Maybe the easiest way to implement this will be just to add your last element as footer using addFooterView