Scrolling images across the screen in android - android

I'm writing an application in which i have to scroll different images one after another across the screen. In order to do that, i create a list of 10 ImageView items. These image view items are placed one after another like train coaches.
The question is how to scroll them from left to right. I thought of using scrollview, but it can accept only one child component and does vertical scrolling.
There is a Scroller class, but i'm not sure how to use it, i mean what does it scroll? I dont see any method like Scroller.scroll(view).
Another approach which i though was to user Layout animation such as TranslateAnimation, but then the end result is kind of shaky.
Can anyone point me to some sample of scrolling image from left to write. I don't want to use the gallery components because it defeats the objective of the application.
Thanks

you can use HorizontalScrollView with a horizontal LinearLayout inside, containing your ImageViews.

You can use HorizontalScrollView with a horizontal LinearLayout inside, containing your ImageViews.
You can do one more thing to override the following method in horizantalScrollview
#Override public boolean onTouch(View v, MotionEvent event)
{
//...
}

Gallery widget would much help you

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.

How can I implement a horizontal scroll view where it aligns to each view inside when scrolled

I'm trying to have a horizontal scroll view contain, for example, three vertical scroll views. And what I want is to be able to have the horizontal scroll view align to each vertical scroll view when you scroll over to it.
I'm not sure if a horizontal scroll view is the correct way to implement this kind of feature, however I found the method scrollTo(x,y) which I think may be in the right direction to creating this.
The best example of what I'm trying to do is shopping for music in the google play store (atleast, on my nexus 7). It allows you to scroll left or right, and it aligns to a screen's worth of content, which you can then vertically scroll.
So, that's what I'm trying to recreate in my app. But I'm confused on implementation details of allowing the horizontal scroll view, to scroll, and stop at a certain point. It looks like I need to override HorizontalScrollView to capture the motion events, but I feel like that's too complex for what seems like a simple task.
Does my question make sense? I basically am at the very starting point of creating this, and need some help as to where to go next.

Recycler View as part of a Scroll View

I'm developing an app that has an UI pretty similar to Play Store. It is organized as a multiple panels one above another. First it has a panel containing a photo. Under that it has another panel containing some text and a custom background color. Under that it has another photo and finally it has a Linear Layout with vertical orientation containing a pretty long list of little views filled dynamically at runtime. I have all this inside a Scroll View, naturally.
The problem? That dynamic fill of the linear layout takes a long processor time and makes my app unresponsive during those inner views inflation. So I thought to replace the linear layout by a Recycler View. And the performance is awesome!
So? Well... Not everything is so awesome. I can't scroll the Recycler View because it's inside the Scroll View. And if I remove the Scroll View then I can't scroll the entire view (some things doesn't fit on the screen).
What's the best approach for fixing this?
It's not recommended to use a RecyclerView or ListView inside of a ScrollView precisely due to the double scrolling issues. RecyclerView is very robust and is prepared to receive headers, footers, etc. I see no reason why the entire layout could not be inside of a RecyclerView instead of a ScrollView
The ViewHolder implementation can include logic to inflate different layouts depending on what section should be next.
Pseudocode:
i.e.
if(currentAdapterItem == sectionA){
useLayoutA();
} else{
useLayoutB();
}
Just use a NestedScrollView instead of a normal ScrollView. It handles the nested scrolling quite well.

How to apply gesture inside scrollview in Android

I am developing Android application which contains the reading of epub books. In that I need to place two pages in book view. If those pages exceed the screen size user have to scroll and view the books and have to pinch zoom the book and user can pan the book for reading.
At first I tried to place two webview inside the Relativelayout. I can achieve this by placing relativelayout inside the scrollview and horizontal scrollview to scroll in both horizontal and vertical.
But problem occur in the swipping of pages and pinchzoom is not working inside the scrollview; it remains in the first page itself. I don't know where I am going wrong.
Are you putting WebView inside ScrollView? It functions funny that way. You'll have to disable the outside ScrollView if you're doing so.
You can modify ScrollView to be lockable, as in here.

Horizontol Scrolling View in Android

I want to create a Horizontol Scrolling View in Android. The view would be a combination of images and text scrolling horizontally and I should be able to dynamically modify the content(text and images) in the Scroller
Any ideas?
add HorizontalScroolView in the scrollview it will scroll in both directions.
ScrollView
HorizontalScrollView
ImageView
You could perhaps also have a look at the Gallery element.
You'd like something like ListView, but in horizontal orientation.
I'd make this to extend AbsListView, which is made to display dynamic lists.
Ideally if you'd copy ListView source and switch it to horizontal mode, but this is very complicated and long class, so look for easier options.
Try using GridView with just one row, stored in a HorizontalScrollView. Feed it with a ListAdapter, provide Views for your cells and setup content to display.
I didn't try this, but it seems like easy solution. Assuming that number of items will not be large, because there won't be optimizations available in ListView class.

Categories

Resources