Pinch Zoom on Android with an embedded ScrollView - android

I have an Android app with an Activity that I'd like to be able to pinch zoom.
The Activity is a LinearLayout that contains several controls, one of which is a ScrollView. I've implemented the zooming by following the very good example here:
https://github.com/Xjasz/AndroidZoomableViewGroup/blob/master/ZoomListView.java
Here's what I've seen:
If I put Finger1 outside of the ScrollView, I can put Finger2 anywhere and things zoom beautifully.
If I put Finger1 inside of the ScrollView, then nothing will zoom regardless of where I put Finger2.
It seems to me that once a finger goes into the ScrollView, the onTouchEvent is not propagated up to the parents.
Has anyone else seen behavior like this? Any ideas on how I can fix this so that I can always zoom if I touch inside the ScrollView first?

Related

How do I cause vertical two-finger swipe behavior to cause a horizontal slider to move left or right?

I have a horizontal slider in my app, and I want to make it so that if you have the slider selected, you can do the two-fingered swipe up or down gesture from anywhere on the screen (The scroll up or down gesture) to move the slider left or right. I haven't been able to find anything through google about how to change vertical swipe behavior for Talkback and was wondering if there was in fact a way to change this.
I'd really suggest not doing this, it isn't how Android works so it will confuse your users, and be a big source of bugs as any behavior like this can cause touch errors on completely separate views. I just fixed a problem on something similar in my company's app.
But if you really want to do this- your root ViewGroup needs to intercept touch events if there are two fingers down and it moves far enough to qualify. Read https://developer.android.com/training/gestures/viewgroup#intercept for an explanation of how a parent view group can steal touch events from the child. This is the same way ScrollView works to scroll its contents. In fact, looking up the AOSP implementation of ScrollView would give you good example code.

Drag views freely in ScrollView android

I have been looking for a solution for this for a while now, What I'm trying to do is an application with drag animation like Tinder, the difference is that I have 3 images at once, one below the other and all of them are in ScrollView. My problem is that when I'm touching to move it up and down the ScrollView takes place, I can move it freely left and right but if I move it up/down even by one pixel I lose it. I've tried to make custom ScrollView that disables the touch of it when I touch the other View's with no luck :(, I thought maybe try and make the views that I want to drag to be at the top of the views with the Z-index and I couldn't find anything about it. I saw some answers like the dispatchTouchEvent and intercepTouch or something like this but I didnt understant how to work with it.
Sorry for my English, Thank you!
Found the answer, I used getParent of the view until I get to the scrollview as parent, and used requestDisallowInterceptTouchEvent(true) that solved it!

How to enable zoom in ScrollView?

How to enable zoom in Scrollview?
Here is an application that uses this function very well and works in API9 and more:
The zoomcontrol hide after 2 seconds without user interaction.
The view you are seeing is a WebView as mentioned by Waza_Be in their comment.
If you want to implement something like this in Android, you can either use a WebView yourself and add text/images etc to this as HTML code. See Building Apps In WebView.
If you absolutely have to use ScrollView you will have to create your own custom implementation.
You could have a RelativeLayout that contains the ScrollView and the two Buttons for zooming in and out. Have the Buttons in their own LinearLayout with orientation="horizontal" and set this to align with the bottom right of the parent RelativeLayout.
That will give you the floating buttons above the ScrollView.
You can then detect a tap on the ScrollView, or when it scrolls using the example given in this StackOverflow article (ScrollView does not support an OnScrollListener as such).
When you detect a scroll/tap, you can then set the Button layout to be visible, and remove visibility after 2 seconds with a Timer or a Thread that sleeps for 2000ms.
To achieve zooming, you would have to increase the of the TextView font size for each (+) click and decrease it for every (-) click. For Bitmaps you could similarly scale the Bitmap to fill the new size.
A lot of work for what you want to achieve. Try to stick to WebView or find another way of representing your application.

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.

Is possible in android to pan/drag a layout?

I am trying to pan a RelativeLayout with child Views, using gesture onScroll event, but I do not get the result that I desire. I have tried to move the children, but nothing works.
Any suggestions?

Categories

Resources