Pinch zoom on a xamarin forms scrollview - android

Im working on an application in which we have a xamarin forms scrollview to which we add several subviews. Each of this subviews has a custom renderer defined in the droid project, as we render some pretty complex objects (adorned text displayed as a elaborated poligon for example).
Now I am required to add pinch zoom for that scrollview (yay me!) is there a practical way to accomplish this?
Thanks for your time.

Related

How to create infinite scrollable and zoomable view android?

I am very new to android programming, and I want to create a large infinite scrolling and zoomable activity where I can add views much like the empty activity we get in the Simple Mind app. Which layout and activity type should I use? What we the best way to implement this? Any help or pointers to tutorials are welcome.
No view in Android is infinite, you're going to run out of memory at some point. The solution you choose will depend on how interactive you need the zoomed view to be.
You can check out android pinch zoom for previous discussions on this topic.
If you're just looking at displaying information and not editing then I'd suggest custom tile maps for google maps.
https://developers.google.com/maps/documentation/android/tileoverlay
I've seen it used before for very high resolution viewing of paintings.

Equivalent of wp7 pivot control on iOS and Android? [duplicate]

does anyone know if there is a UI widget out there for android that is like the windows phone 7 panorama or pivot controls? if not, is there any tutorial that would guide me down the right path in implementing my own?
any help is appreciated. thanks.
Yes, I was interested in the Pivot controls also.
Here's the best working resource I've found for Pivot-like functionality: http://viewpagerindicator.com/
Or, if you would like to see the official Android Developers' Guide about this, called ViewPager: http://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter.html
Not sure I entirely get what you want, but looking at this Pivot really is just tabs: take a look at the Tab Widget tutorial. Panorama is a bit more tedious: you can try embedding the View you want to pan into a HorizontalScroller. If it is wider than the screen it will let you scroll around horizontally. To get vertical panning as well wrap that with a ScrollView.

Gestures and OpenGL

I'm using OpenGL ES on android 2.3.3 at the minute to render a simple 3D game. I'd like to extend it using the built in gestures library, but I can't find a way to recognise the gestures from a GLSurfaceView as opposed to an android view(I don't have an XML layout is what I'm saying)
Is there any way to either implement an XML layout on top of what I have already, or preferably to implement the gestures library on top of the GLSurfaceview instead.
Thanks.
You can attach a normal onTouchListener to GLSurfaceView, so long as you have an instance of GLSurfaceView (which it sounds like is what you have). This is only really useful if you just want to know the raw x,y coordinates on screen where the user has pressed (e.g to rotate around the y if the user moves their finger left/right across the screen)
For gesture library, which I haven't used myself, you should be able to just place your GLSurfaceView inside a frame layout and then place another view (e.g. linear layout set to match_parent) in the same frame layout so that it completely covers the GLSurfaceView and is on top of it. Attach the gesture library to this view (and obviously make sure it is transparent so people can still see the GLSurfaceView below).
The gesture library has a way of 'stealing' events from the view. See here for details.
Here, here, and here are some examples that should make it clearer.

set the origin (x,y) of a view inside of a RelativeLayout

I have some game pawns on a screen inside of a RelativeLayout. When the user clicks the pawn I would like then to be able to drag it under there finger. I have the MotionEvent captured but can't seem to find how to adjust the orion of the pawn.
I've seen posts saying to adjust the margin but that seems questionable. I still want to do hit tests for the pawns after they've been moved and don't understand how to work with the margins in that case.
thanks!
I would recommend not using a Relative Layout at all.
A Canvas is a much better option
Or if you really want to use a layout, possibly an AbsoluteLayout is a better option
Using a layout for a game may prove unsatisfactory as you proceed. I can recommend using the free and open source game engine AndeEngine for making 2D games. The problems you have with collision detection and x,y positioning are trivially easy to implement with it. I've made 2 games and a visualization view within an app with is so far.
Check it out here:http://www.andengine.org/
You can download the demo app to your android device and see its out-of-the-box capabilities. (They include Sprites, sound, animation and more.)
This one game I made with it.
https://market.android.com/details?id=com.plonzogame&hl=en

Android components for displaying a graph (nodes and edges, in 2D)?

I'm at the starting point of developing an android app similar to a "mindmap" program (like Thinking Space). It shows some graph nodes (containing text, maybe images) and edges that connecting them. I can take care of graph algorithms, but I have two uncertain points about Android components for displaying these things:
The expanded graph will be pretty big, so the user need to be able to scroll both vertically and horizontally. I looked at ScrollView and HorizontalScrollView but they can't scroll both vertically and horizontally. So I hope to know which top level container I should use.
I also want the graph to be zoomable with pinch gestures, so that the user can zoom in to a small part of the graph. But I also want the graph nodes to be interactive, so the user can tap on them, typing text into them and move them with fingers. Should I implement each node as a separate View object? If so, how do I make all the nodes zoom together?
Thanks.
I would definitely rely on custom views for this kind of things, they will give you much more freedom and efficiency than using standard layouts.
Implementing a scrollable view is quite easy, and implementing the pinch gesture will be much easier if you're supporting API >= 8 (see ScaleGestureDetector). Making graph elements interactive and editable would be another thing, though.
Something really much better could be creating a custom layout, that would host editable graph elements (custom views) and draw their relations. It would be much more elegant, clean, expandable, maintainable and reusable, but it would need a lot more designing. Yet I'm sure it would be greatly rewarded.
(This would be quite an ambitious project for me, so... good luck!)

Categories

Resources