Listview with column flow - android

I want to add views to Horizontal listview (custom). The way i want to add them is:
Add a view (all views will be of width screenWidth/2) at top left of
the screen.
Add next view below that view.
Keep adding till the bottom of the screen is reached. When there is
no space for another view to sit, start adding to a new "column".
I have achieved this with a simple LinearLayout, now i am not getting any ideas how to do it with a ListView. The reason behind choosing a list view is that my app might contain thousands of such child views, and list view helps in keeping only those views i nmemory that are currerly needed.
Any help is appreciated guys.

You'll need to place GridView in HorisontalScrollView and sweat a bit to make it work. See here

Related

Display list without scrolling

I want to display a list without scrolling vertically. if list height greater than the parent list must start from the next column. if column fit to the parent it must scroll horizontally. Image shows what I want. please help me to solve this problem
In that case you can use a constraint layout. But the logic to break the list should be implemented by you when binding the adapter with the data and view. Recycler view will be a good container. I hope this sheds some light.

Recycler View Scroll to middle of screen

Hello I am not sure if this would be a duplicate as my wording is probably not the best to describe this on a search. I have a recycler view with a list of strings. Everything works great however, is there a way to make the list scroll a little higher than the bottom of the parent view, in this case keep scrolling up until it hits the middle of the screen? the Recycler view would height is match parent. Thank you in advance!!
Please note: I didnt add code since this is just a regular recycler view nothing special added, let me know if the code is needed as well thank you!
Edit:
this is for a vertical scroll list only. The following images are some list images I got offline but hopefully they can show better what I am trying to accomplish:
I want to be able to scroll the list up to the middle as in the following picture for example:

A recycler view vs the linear layout inside a scroll view?

Am trying to create a page with a scrollable list. Features would be a normal list to remove item by clicking on it. Number of items in that list are limited and added dynamically by user. You can consider a to do list as example. Now which would be a better approach to implement it? Recycler view with data bound to its adapter? Or the normal linear layout with items added as children at run time?
My current implementation is recycler view. But,I found it lagging and animations are not performing well. So a linear layout is auto animated by specifying it xml -- by setting animate layout changes to true.
FYI data is local and syncs in background.
Never use a LinearLayout for anything longer than a single screen. The whole point of ListView and RecyclerView is to efficiently reuse views instead of needing to hold things in memory when they're not visible. Maybe you can refine or reask your question so people can help you with whatever difficulty you're having with animations, rather than avoiding the issue.

Android Drag-n-Drop grid with LinearLayouts as drag items

I have a working example of a grid that allows items to be reordered using long touches to active a drag-n-drop. All is working well if the items are simple Views e.g. TextView or ImageView but if the items are LinearLayouts only the layout itself is displayed.
I've been using Tom Quinsn's grid (thanks Tom!!!) from this posting:
Android Gridview drag and drop example
I can get LinearLayouts to work if I derive my own LinearLayout class and override onLayout(), but this forces me to hardcode the positions of the child controls in the layout within this function.
Ideally I would like to be able to define the item layout within an XML file and inflate them before adding them to the Control that handles the grid. I'm guessing that for some reason the framework is not calling the layout function for the children contained within the DraggableGridView view as defined in Tom's code but I can't understand why that is.
I am developing my own Drag and Drop app with good help from this link. You may compare the code with the one from Tom Quesinsn. It also gets the different children of a GridView and add them as "drop targets" that accepts drops on them and copy the Image of the View you are dragging.
This is a known problem with the DraggableGridView that -- unfortunately -- I haven't gotten around to fixing. When I wrote DGV, I didn't entirely grasp how views were laid out. You might try having DGV measure each child before laying it out. Adding something like:
getChildAt(i).measure(MeasureSpec.makeMeasureSpec(childSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(childSize, MeasureSpec.EXACTLY));
before the layout on this line:
getChildAt(i).layout(xy.x, xy.y, xy.x + childSize, xy.y + childSize);

Is it possible & efficient to put a LinearView and ExpandableListView inside a ScrollView

I'm making a GUI with two different parts. The first part (at the top) is composed of some banners, several fixed buttons. So I think using LinearLayout is the most straightforward way to implement. The second part is composed of several similar items grouped together which can be implemented by using ExpandableListView, I think.
However the problem is that the content exceeds the screen size. So I intend to put two of them into a ScrollView. I checked several sources, it seems that putting "ExpandableListView" inside a ScroolView is NOT possible, or not efficent, so I'm afraid...
Would you help to confirm if this is possible? efficient ?
If no, would you give me some recommendations for this layout design?
I'm indeed looking forward to your supports.
Sincerely.
If you have a fixed header at the top of a list, use ListView's header view feature.
Putting ListViews in ScrollViews fundamentally makes no sense and here is why:
ListView has one purpose: to efficiently display unbounded data sets. Since these can be extremely large (tens of thousands of items and more) you do not want to create a View for each item up front. Instead, ListView asks its Adapter for Views only for the items that currently fit in the ListView's measured space on screen. When an item's View is scrolled out of sight, ListView disconnects that View and hands it back to the adapter to fill out with new data and reuse to show other items. (This is the convertView parameter to an Adapter's getView method.)
ScrollView also has one purpose: to take a single child view and give it "infinite" vertical space to fit within. The user can then scroll up and down to see the full content.
Now given this, how many item Views would a ListView create for a 100,000 item Adapter if it had infinite height available to fill? :)
By putting a ListView inside a ScrollView you defeat ListView's key purpose. The parent ScrollView will give the ListView effectively infinite height to work with, but ListView wants to have a bounded height so that it can provide a limited window into a large data set.
Well Expandable List View itself has scrollable property by placing it in scroll view is really undesirable.As the both scroll would contradict and smooth scrolling can't be obtained in that case..
If we have any data to be shown prior or later to list...
Best way is to use header and footer view to list...
I recommend you use header and footer in your case.

Categories

Resources