How to create lazy loading in Horizontal scrollview - android

My application loads 10 image-thumbnails from server and set them into horizontal scrollview. When I swipe it to the last image, I would like to add lazy-loading element in the back of my horizontal scrollview and download next 10 more image in the background process.
My problem is -----> How I know the last image in horizontal scrollview shows on the screen?
I think the horizontal scrollview is so different from listview, because the listview uses adapter to control inside elements.
Thanks you so much

Maybe you can use a ViewPager http://android-developers.blogspot.com/2011/08/horizontal-view-swiping-with-viewpager.html
This uses an adapter behind the scenes and you can do the trick where you set the count to a very large number.

Related

How put Horizontal View and Gridview inside Vertical Scrollview

I want to develop an app that includes GridView and I want it to be some thing like horizontal ListView above a gridvew .Horizontal view displays images downloaded from url.I saw this touturial ( horizontal scrollview used)
and saw this to put the GridView inside scrollView because i want to put the gridview(episode #2) and horizontal view (episode #1) in vertical scrollview(episode #3) . I need to scroll the horizontal view vertically when a user is scrolling the gridview and not to have fixed position at the top of the screen.
I have no idea how to do this (use horizontal ScrollView or horizontal Listview)?
after vertical scrolling I want it to be like this (horizontal view must get scrolled vertically):
This is a custom interaction, so you probably will not be able to use a "standard" tool for this. You may want something like the FloatingActionButton (an example here: http://antonioleiva.com/collapsing-toolbar-layout/) but you also want it to scroll, so you may need to extend that class.
Also, you could use touch events to do a custom animation on the area, because you will need to track when it is displayed and the direction/distance of the motion event to collapse/expand it. You also would need to know anchors on the list, to determine when it should reappear...
This is a cool design concept, but usually "cool" = "difficult" because it's not standard.

Android : How to load images in Horizontal Scroll View only it is visible

I want to add some images to an Horizontal Scroll View and want these images to be loaded only when the user scroll the horizontal scroll and the image come to the visible area .
I built a custom layout that extends linear layout to hold the image
And tried to add the loading of the image to
onFocusChanged
onWindowVisibilityChanged
onWindowFocusChanged
but nothing is working
any help ??
This type of problem is better solved with a RecyclerView. It'll handle horizontal scrolling, image loading when views becomes visible, and recycling views for better performance over large data sets. Among other things.
There are tons of tutorials out there, find one that suits you're style and dive in!

Scroll before ScrollView is loaded

Hello, I have a question,
Is there any possibility to skip the first scroll's that occur before gridView is loaded?
To get only those when user really scrolls my list?
I am loading more, and that scroll before any user action is messing up.
How are you loading the gridView?
If you load it using addView you probably won't have problem.
In my opinion the best solution is to create a scrollView that contains a LinearLayout (for example vertical), then add at this LinearLayout a list of LinearLayouts (horizontal), and every layout contained in list contains yours elements.

android.widget.Gallery inside a ViewPager?

I need to place a android.widget.Gallery inside a view pager at the bottom. The user will read and scroll all the way to the bottom and than see more pictures to view inside the Gallery at the bottom. I want to be able to scroll horizontally through the Gallery w/o switching pages. So when the user is interacting with the Gallery, I don't want the horizontal swipe of the ViewPager to take over and switch pages. How can this be done?
I don't recommend horizontal scrolling item in a horizontal scrolling viewpager.
To try this you have a couple options, lots of items: 1.) search horizontal list view. less items: 2.) horizontal scrollview. I guess option 3.) use gallery even though depreciated.
However, I encourage you to try it, it just doesn't work very well with two items scrolling the same way.
For the same reason it's not a good idea to have a vertical scroll inside another vertical scroll.
About the only way this can work is if you give the user a separate full screen non-horizontally scrolling window with your horizontally scrolling item.

Scrollview inside listview issue in android

I am adding a listview inside a scrollview in xml that xml(Screen) is loading from the middle screen. In my design I have a top part like a textview and a list view and middle part like editext and bottom part like button. Page is loading from the middle part. If it scrolls I can only see the above part. I want to load the page from above part. Can anybody tell me what the problem is and how to resolve it?
Thanks
Use android:fillViewport="true" as an attribute in your scrollview tag and it will fill up the screen.
Actually there is no need to use ScrollView with ListView. Use ListView only, you will be able to scroll the items in a ListView.
You should never use a ScrollView with a ListView, because ListView
takes care of its own vertical scrolling. Most importantly, doing this
defeats all of the important optimizations in ListView for dealing
with large lists, since it effectively forces the ListView to display
its entire list of items to fill up the infinite container supplied by
ScrollView.
found it here
using smoothScrollTO(0,0) to fix the issue

Categories

Resources