Android - Image zoom library - java

I have this kind of use-case
User is looking at ImageView, this ImageView should implement two types of gestures:
Swipe left/right to move to previous/next image
Zoom image (two-fingers, double-tap)
For swipe I've used implementation from here https://stackoverflow.com/a/8806468/492624
You can see it here: https://github.com/smarek/Simple-Dilbert/blob/master/src/com/mareksebera/dilbert/ActivitySwipeDetector.java
For double-tap, two-fingers I've used library named PhotoView
You can see it here: https://github.com/smarek/Simple-Dilbert/blob/master/src/com/mareksebera/dilbert/ImageZoomActivity.java
The problem is, I'm not currently able to combine these two implementations.
I'd like user to have both options on one page, one idea is to rewrite it from "single ImageView" to "ViewPager", to implement paging on lower level (not as OnTouchListener) and use PhotoView as library to provide zoom function.
Possible user-scenario is for me:
If image is not zoomed, user can use swipe gestures to move through images
If image is zoomed, user can work with zoom and move in zoomed image, but left-right swipe will not work in this case, so user will be forced to un-zoom it to be able to display another
So two qeustions are on the table
Whether my user-scenario is right and understandable
If there is option to combine these or use another library without need to rewrite it to ViewPager

Can't you just use the code from sample of PhotoView?
This works well for me:
https://play.google.com/store/apps/details?id=uk.co.senab.photoview.sample

Related

How to place comments on a full screen image?

I'm working on a native android application in java with Android Studio and I want to add comments on full screen images like this. This based upon a feature of "Figma" where you can place comments on prototypes.
I have already made a xml file that normally has an Imageview in full screen. So I probably need to draw a circle on the exact coordinates of the view where I click. So how can I achieve this in java code?
Figma example 1
Figma example 2
use draggable view and when user clicks it display dialog where they can enter a comment,
then save the position of the view and the comment to SQLite or wherever you want so the user can retrieve it again whenever they need it

Create a view class that is a combination of two views Android

In my app, I have a screen that displays some images next to text. These images are downloaded from the internet, so there will be some latency in displaying them. Right now I have an ImageView and a ProgressBar overlaying each other, and toggling the visibilities when the Bitmap becomes available. Is there any way to combine the two into one class that will handle it all in case I want to use this somewhere else?
One way to go about solving the problem is to make your own custom view which extends ProgressBar and draw the image in the ondraw(Canvasn canvas) using a Rect. That way, your image can be embedded in your view and you can always make it reusable by allowing your self to set the image via a setter/resource xml files which specify the attributes that go along with your custom view. Here's a reusable ProgressButton that I wrote that maybe of use to you, it shows how I did something similar to what I described (it's one which I think works well):
PregressButton
Yes there are a number of ways to combine widgets into a single custom class. Have a read of Custom Components. This should help you decide which approach you want to use for your situation.

Possible implementation of game screen concept for an android game

I want to develop an android app, but I'm still not that great at using xml or the eclipse wysiwyg editor to make scalable and robust interfaces!
Below is a quick concept I drew up on word of what my main game screen will consist of:
I'm currently thinking a vertical linear frame first, with a frame that doesn't change for my important stats etc., then a frame in the middle which is switched by the buttons, but I'm stuck on how to implement this.
For the centre button screen, the map screen, I am hoping to add an image of a map which can be moved around, and somehow attach invisible button objects to points in this picture, maybe with an array of squares or something?
I understand this is a pretty open question and might be difficult to answer, but if you think you can help in anyway please do.
Thanks!
There is a log of possibilities, but you can use a LinearLayout with android:orientation="vertical" and include your stats in top. For the changing screens with buttons you can use a FragmentTabHost and create different Fragment for each of your views.
Check this example with a implementation.
Regarding the map, I think the easiest option is to use Google Maps Android API v2. Here is a example to use the maps v2 and a example of how to add markers to the map.

Java android ImageView with zoom

I have been searching for a view that can handle this. What i want is to allow the users to zoom in/out of an image.
Right now i can not find any pre-built solutions for this except the WebView. One could argue that Google should actually offer this without having to resort to the WebView (That one limits the layout possibilities).
I would like to have the same built-in functionality like for iPhones/iPads.
So question is, what user-built views are there out that could handle pinch-zoom in/out of an image?
I have tested 2 different custom made solutions but neither worked as expected. One managed to re-size, but only in one direction at a time (either horizontally or vertically) and the other did not even work.
Update: It should be possible to use the solution with Android 2.3+. (Majority of the users are in that range)
I've found one very interesting few days ago. I think it's the best one I've seen. You can zoom with a double tap, pinch, has acceleration with movement, etc.
Take a look here.
There are several Android view libraries that can handle what you are looking for.
Check out these
https://github.com/chrisbanes/PhotoView
http://code.google.com/p/android-pinch/
https://github.com/jasonpolites/gesture-imageview
I achieved good results with this library: http://blog.sephiroth.it/2011/04/04/imageview-zoom-and-scroll/
It is not a total drop in replacement for imageview but it also works in a Viewpager where the Viewpager handles horizontal Swiping for page changes.
Starting with Android 3.0 (API Level 11) you can zoom every view using setScaleX(), setScaleY(), setPivotX(), setPivotY() etc., or just using setMatrix().

Android most efficient way to have many views

I have an app that will allow the user to drag many views onto a "canvas". The user can pan, rotate, flip, and scale these views. Each view will need to have a image on it. I was thinking of simply inflating imageviews and letting the user interact with those.
Is there a more efficient way to have up to 50 images on screen that can be interacted with?
If so, can you point me to some code examples?
EDIT:
I have noticed there are multiple ways to do this:
Some tutorials use a surfaceview and bitmaps and threads
Other tutorials use open gl
Other tutorials simply have views on views,
What route should I take?
Thanks
Check out this app:
https://market.android.com/details?id=com.sunshine.fingerpaint
By using a Horizontal Scroll View at the top of the application, you could inflate the 50 images you want and let the user interact with them.

Categories