Android listview items with horizontal scroll - android

I would like to use horizontall scrolling items in a vertically scrolling Listview.
Note that the items should scroll horizontally independently of the other items, i.e the whole list should not scroll sideways when dragging sideways.

Take vertical scroll first and in that vertical view take a table row and in that row take Horizontal View. Do these as many time as much you need horizontal view in vertical scroll view......
for easy implementation use TABLE and its Rows instead of vertical view

This should be the code for you list-view-item:
<ScrollView
....attrs...>
<!---Your layout---->
</ScrollView>
Use this layout as one row of the list view and this should work well.
Also if you already have a code for the adapter class, you wont have to make any changes to it.

Related

How to create a custom layout with cards scrolling horizontal and posts scrolling vertically( recycler view ) which should work with pagination

enter image description here
Here what I tried:
I can able to achieve this layout using Wrapping Horizontal scroll view and recyclerview inside Nestedscroll view.
The problem is :
When I put recycler view inside any of the scrolling containers such as scroll view or Nested scroll view
Its loading all the items in recylerview at once which is not a implementation of recylerview,hence pagination is not achieved.
Requirement:
1.Top header cards should scroll horizontally which is of a (fixed) Limited size.
2.Label for the vertical scroll view
3.Recycler view for vertical scroll of items
All the above should scroll vertically.Please help, or suggest any better way doing this layouot.enter image description here
Yes you can achieve this by having parent layout as <nestedScrollView> and in child you can take 2 recycler view of which one of them should be horizontal and another should be vertical.
set property android:nestedScrollingEnabled:true and your are good to go.

Android two way scrolling Listview

Let's say I have 100 rows of data to show in a ListView. So far no problem. I have a custom adapter for each row, that has a TextView for a date, a TextView for a sequence number and NOW 60 more TextViews, mostly having a two digit number.
How can I get a horizontal scroll to show all these 60 numbers, BUT, the vertical scroll for the Listview should still work, to scroll down from 1 to 100 row, and also, all rows shown on the screen shall scroll horizontal at the same time, not that only one row will scroll horizontal.
Had tried TwoWayView, but only allows to define one direction of scroll.
You need to have a horizontal scrolling list as each ListItem. Although, there are several horizontal scrolling view options, I would recommend using a Recyclerview with a LinearLayoutManager and orientation set to HORIZONTAL.
The general idea is you need a horizontal list as a list item.

Nested Horizontal view inside RecyclerView

I want Horizontal scrollable items in vertical recyclerView. horizontal items will not be more than 10 in any case.
I thought of two approaches
1) Horizontal Recyclerview as item in vertical RecyclerView
2) Custom horizontalScrollView as an item in vertical RecyclerView
I have implemented first one facing some issues in scrolling but I think I will manage that.
My question is, why not second approach. I have seen all related question on SO and most of them trying to do with first approach. Why is it so?
What is disadvantage? specially I you have limited number in horizontal view.
Any pointer would be great help.
Why do we use RecyclerView instead of LinearLayout?
Because if we use a LinearLayout consisting of (let's say 50 items) they will be all rendered on screen (50 Views) and this will lead to very very bad performance issues and scalability issues. RecyclerView does initialize the views that appears on screen only ,let's say 7 views, and they will be recycled in every new row that comes.
Why do we use Horizontal Recyclerview instead of Horizontal ScrollView?
This is not usually the case. If you have multiple items in every row that needs to be recycled then you should use Horizontal RecyclerView otherwise it won't matter at all.
To summarize,
The views in the vertical RecyclerView will got recycled whether it has another horizonal RecyclerView or Horizontal ScrollView, but the views inside the Horizontal ScrollView will not get recycled and the views inside the Horizontal RecyclerView will got recycled as it's a RecyclerView.
If you don't have multiple items in your Horizontal RecyclerView, you shall use Horizontal ScrollView instead.

Android ListView with a focusable elements in a row

I'm working on custom app for TV platform.
I need a something similar to grid view but much advanced in my app.
I need each row to be independent and to scroll independetly from others.
So I have created normal vertical ListView...and in each row I have custom horizontal list view...
Now I have the problem that my horizontal list views element can get focus from vertical list view.
Vertical list view doesn't need to be clickable, it just needs to scroll up and down and give focus to horizontal rows.
In horizontal list view elements I have the real content which is focusable and clickable..
I have tried with different paremeters setFocusable, setClicable, setFocusableInTouchMode, setDescendantFocusability...
But nothing worked, I can't get focus on horizontal list.
Also I'm not using touch events, but remote controller.
Tnx in advance!
try to override dispatchTouchEvent or onInterceptTouchEvent

How to combine scrolling of ListView and TableLayout in Android

I had a ListView and a Table Layout in a horizontal linear layout. I want to combine scrolling of both the views i.e., if I scroll List view, the table layout should also be scrolled and vice versa. I cannot use a scrollview, because it is not recommended to put List view inside a scroll view.
Please suggest,
I don't understand why you would like to put a listview in a scroll view?
Because a Listview already is scrollable as far as i remember...
It sounds a little bit strange.. You have horizontal rows (horizontal linear layout) within a table which are horizontal and vertical rows (rows/colums) within a listview which is already scrollable? And a listview are horizontal rows again..
Edit..
Or i don't understand you well, and you have a listview and a table layout in a horizontal layout. but then you can but the table layout within a scrollview.. this way the scrollview doesn't contain the list view.
Please explain in more detail what you are trying to accomplish!
Well, if the ListView is small enough so that it can be scrolled simultaneously with a TableLayout then maybe you could simply replace the ListView with a LinearLayout and put both the TableLayout and the LinearLayout in a ScrollView.

Categories

Resources