multiple screens to scroll horizontally, but not vertically - android

I am trying to achieve multiple scrollable views on one activity.
I am using viewpager, in each screen there will be multiple buttons using baseadapter, where clicking on one will start certain level, similar to what you see in many of the current games.
I managed to do this and it is all good, one thing I couldn't do is to stop the page/buttons from scrolling vertically, even when all buttons are already on display, you still can scroll them up and down :(
when you scroll horizontally, it goes to the next/previous page, that is good, but how to disable scrolling vertically?
I am considering doing the hole thing in canvas, and make it from scratch, I just don't want to do it the hard way and want to learn the easy way of doing it, if there is any.

Related

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.

List with views stacked on top of each other

You usually traverse a list by scrolling through the views that are placed one after another. What I'm trying to achieve is similar, but the views would be stacked on top of each other. The views will also cover the whole screen. So when you scroll, the top view slides away (or uses some other transition animation), but the bottom one is not moving underneath. You can imagine that the views are like the papers in a top spiral-bound notebook.
So my question is - does something similar already exist? I haven't been able to found anything so I might need to make a custom implementation. Oh and the views will each contain an image and there might be quite a few of them, so it will need to handle that (I was thinking of using Android Universal Image Loader). Thanks.
Sounds like you want to use Depth page transformer, via http://developer.android.com/training/animation/screen-slide.html#pagetransformer

Android ListView for showing lyrics

I am trying to make a ListView for showing lyrics. I have very little experience with making custom compound views. So I would like to know what my approach should be to make this view. The ListView must have these features
auto-scrolling based on the song (the timing information will be stored in the list adapter)
highlighting the current line which is being played on the audio
indentation on some lines to make it look more like a nicely formatted poem
users should not be able to scroll the list when the song is playing (i.e. the list is being auto-scrolled) but it should be scrollable when the song is paused
I don't know if the view should extend list view or not. If not then what should it extend and what should be my approach?
Frankly, I really don't have enough information to answer this completely, but this is what I would do:
If it were up to me, since you don't want a scroll capability at all (you want to make it appear as if it is scrolling, not to actually allow the user to scroll), I would not use any of the complex views like ListView or ScrollView, I would just write a custom view, simply extending View. I would override it's onDraw() method and use Canvas.drawText(...) to draw the words, having two different Paints, one for the current word and another for all other words. As for the "scrolling" effect, you can keep a number that represents the current top line that you can see, and add one to this number when you want to scroll to the next line. However to make it smooth you can manipulate where exactly you start drawing the texts and move it slowly upwards, so that it would appear that everything is scrolling down.
** Maybe it would be better to use SurfaceView here instead of just View, especially if you want a background image and smooth blending and better a look, since SurfaceView is much better for complex drawings **
If that is too complicated for you and you want to use existing views entirely without doing any of the drawing yourself, I would recommend a vertical ScrollView, you fill the ScrollView with horizontal LinearLayouts for each line, and each of those is filled with TextViews for every specific word. You can programatically build the TextViews and the LinearLayouts. Use ScrollView's scrollTo(...) or SmoothScrollTo(...) to scroll to the right location. You can prevent the user from scrolling by capturing all the motion events before they are used to scroll.
Both approaches will of course require you to maintain some form of data structure to hold the times each word is selected.

Android Gallery Jumps when swiped quickly or slowly

I've made an activity that looks a lot like the level select screen from angry birds: there is a grid of button, and you can scroll through pages of them by swiping right or left.
I built it by creating a layout of the buttons, and then adding those layout to a Gallery view.
The problem is the animation is jerky, even if you swipe extra slowly, the content jumps ahead. Even when you fling the gallery page, it skips and jumps along its way to its destination.
I am wondering how to fix this: Maybe the complex layout it making it non responsive during the inflate?
Do you know how to fix this, or of a good way to do a workaround using some other approach that will let me have 3 or more screens smoothly swiping from page to page?
You should be using ViewPager. This is available in android support packages. Gallery Widget will not be smooth if you add components into it which has a lot of touch actions.
http://android-developers.blogspot.in/2011/08/horizontal-view-swiping-with-viewpager.html

Android viewflipper flicker

I have a ViewFlipper with multiple views added dynamically. I override onTouchEvent (and onInterceptTouchEvent) in order to get the down, move and up events on the views, so I know when to animate left and right.
Now everything works fine, except that there is a small flicker (one of the other views is displayed on top for a split second) at the beginning of the swipe. This only happens after the first swipe is done.
I looked at the source code for the Home screen app on Android, which helped a lot, but they don't use the ViewFlipper, so it's a little different.
Did anyone encounter the same problem?
Thanks!

Categories

Resources