When we use a scroll view and Recycler view - android

In a app we have a activity which displays a list of textview let us take a list of numbers 1-9 or more than that.Which view is useful to display textviews either scroll view or Recycler view?

Recyclerview itself has scrollbar implemented in it. It is used when you have a large dataset.
ScrollView is used when you have a limited set of children on your UI and they are fitted out of your screen, so ScrollView is implemented here to scroll your layout to see all the children.

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.

addHeaderView or addFooterView not available in Recycler VIew

I was trying to design my screen as of same in Swiggy App. First, it has horizontal recycler or horizontal scroll view.
Second, it has tab bar which will stick on the top once we will scroll up. Third, it has a vertical recycler view or maybe listView showing restaurants.
So, if we have vertical listView, it's very easy to stick that tab bar(view, the second thing on screen) on the top.
You can see an example here: https://dzone.com/articles/creating-a-listview-parallax-effect-with-a-sticky
But in case of RecyclerView, it doesn't have any direct method addHeaderView. So how do we implement this with RecyclerView.
Use getItemViewType method and create three view holders for first, middle and last items.
RecyclerView with multiple view type

Getting click on empty/whitespace of recyclerview

I need to show images in horizontal RecyclerView, and this RecyclerView is inside a row of RecyclerView. Now sometimes I receive 2 or 3 images and sometimes more that can fit in its width. So, i want it to be Scrollable when there are more items then its width and when it lists few items then i want empty area to be clickable as well. How can i achieve this behavior?
The problem i am having is concerned in first row where the area need to be clickable is not in my control.
I know, This is old question. But I was stumbled upon a similar scenario.
Place the recycler view inside card view (card view is actually a frame layout) and set the recycler view width to wrap_content instead of match_parent. and the card view (parent of the recycler) width to match_parent. This will give you the expected result.
The card view is required, if you want to have the elevated cards for wrapping the recycler view. Otherwise any ViewGroup (like LinearLayout,Framelayout) should work.
You'll need to add a custom GridlayoutManager. Check this https://gist.github.com/ArthurSav/5f80e19d9ba6d562fbd5
from Arthur's Answer

how to move all the Layouts up when scrolling more in the list view in android

i have a fragment which has a stationary Image View at the top , some linear layouts to display the texts and List View at the Bottom. i want the entire screen to go up(that stationary Image View and middle part) when i scroll down in the List View.
I tried to place all layouts in a single Linear Layout and put it inside Scroll View since it has only one direct child..but that makes only the List view scroll able.
Try using CoordinatorLayout and scrolling behaviour from the design library.You can find a great tutorial here

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

Categories

Resources