Prevent Gallery images from overlapping without using setSpacing - android

Is there a way to prevent gallery images from overlapping without using setSpacing?
My gallery uses auto rotation made with g.onKeyDown(KeyEvent.KEYCODE_DPAD_RIGHT, null); which is apparently is the best way to accurately scroll it programmatically, but unfortunately setting spacing prevents onKeyDown from working, for some reason.
Or maybe there is a way to remove spacing (not setting to 0)? Idea is to remove it right before scroll and set back after scroll.
Would be glad to hear any advices.

If your problem is to remove image overlapping in a gallery, then there is already a solution.
How to controll overlapping of gallery images?

Related

How to build a large image viewer

I need to build a component to view large images.
I cannot put the ImageView in a ScrollView because I will need to be handle other touch events on the image.
The ideal would be to build a "viewer"
with an horizontal handle
and a vertical handle
that enable to move where the picture is centered so that I can scroll the image using the handles without touching the picture itself.
I would like to achieve something like in the following picture, I have researched but I was not able to find any Android API or other component/library that I could use.
Thank you very much for any suggestion.
Best thing I can think of is use two custom scrollbars for the horizontal and vertical scroll. In an onChange() function you can change the crop area on the master image and display the cropped image. Depedning on how it is done you can get a slide effect going for the image.

Image auto scrolling in android

I want to create an image auto scrolling for an outer-space type of game. To make it more exact, I want to load 2 background image that uses a single image occupying the whole screen and auto-scroll it alternatively to create an animation that the background image is moving. Don't get confused with auto scrolling and and shifting to another image automatically. I really meant auto scrolling like moving background using 1 image.
I did some research but what I saw are segments of java codes that made me confused. If possible can anyone provide me an example? From loading the image from xml (should I use an imageview with this? or just set the background image of the layout?) and how I should process it in java code to make an image autoscrolling.
Any ideas guys? Thanks! Sorry for asking too much.

Simulating Horizontal Scrolling of GridView using Gallery but scrolling Tables not Images android

I've come to the conclusion there is no Horizontal Scrolling for gridView. The work-around solutions online are to use Gallery in a multi-row format.
However, from what I understand, Gallery requires image files. (Please correct me if I'm wrong.)
I want a work around that can scroll tables (aka a grid view) . I'm basically making a Calendar where I'd like to scroll horizontally. It doesn't have to be as fluid where scrolling vertically shows each additional week that comes into view. Horizontal scrolling can simply scroll month by month.
Nevertheless, I'm wondering if there is some sort of work-around with Gallery? Or does Gallery absolutely require images?
Ah I'm a noob. Figured it out on my own. Here's a link for people who want to learn how to do it with Gallery, but I just came across ViewPager which does the same and I believe my answer will be found there. Thanks!

Full-screen gallery scrolling problems

I'm building an app based on a card game. A user may look at his own cards; he can also scroll "around the table" to look at the open cards of his opponents. The screen shows one player (the user or one of the opponents) at a time.
I used Gallery to implement it. With a custom adapter, I made it circular. I have also intercepted onFling() to make sure it "flings" to the next player, not further around the table. So far, so good.
Here is the problem. If the element of the gallery is as wide as the entire screen, gallery does not work well. I can't drag the view "slightly" to expose the next player. Most of the time, the fling does not work. When it does, there is no animation; the view just switches to the next player.
I solved it by making gallery elements 2 pixels narrower than the screen. 1 pixel is not enough: it fixes scrolling in one direction, but the other direction is still "stiff".
I'm writing this for two reasons. First, if you have similar problems, this post may save you a few hours. Second, I'm curious: can any of the Android gurus explain this behavior of the Gallery control???
I did the same kind of stuff but with a HorizontalScrollView. Maybe you should try with this instead of a Gallery.
You just have to set an OnTouchListener on the view and adjust the scroll when the onTouch catch an MotionEvent.ACTION_UP.

How to change the centering-changing-point of the gallery?

I built a gallery. The centered image is scaled up. I did this by extending from gallery and overwriting getChildStaticTransformation. There I modified the camera. It zooms in when the image is close to the center point.
Problem: the centering item (from getSelectedItem()) changes a bit too late. sometimes the side elements that are smaller than the next coming get re-centered.
Is there any way to tell the gallery when it has tochanng to its neighbor?
Thank you so far.
I figured out this actually depends on the spacings set by setSpacing. If this paramter is 0 the gallery centers correctly as I want.
Problem: the Images spacing are to big then.
Is there a way to minimize the spacings without setSpacing in an artificial way?
Thanks

Categories

Resources