Scroll Image View to Top Programmatically - android

I am using TouchImageView in my app to display images.
https://github.com/MikeOrtiz/TouchImageView
As far as I know, Android does not have an easy way to show an image Top Cropped. The best I can do is to Center Crop the Image, which causes the top and bottom of the image to extend off of the screen.
Is there a way to programmatically scroll my image after it has been loaded, and then call ImageView.setVisibility(true)?
I've tried image.scrollBy(int x, int y);
but I'm not sure exactly how to use it.
I do have the ability to get pixel values for both my screen, and for my image before it is scaled, but don't know what function I should use those values in.
Thanks for your input.

Related

Unity UI Image Center Crop

I am working on listView item in Unity and stuck at fitting the image properly in UI Image. I tried multiple things using Preserver Aspect Ratop, using Filled image type almost every thing but could not make it look fine. In android we call it center crop what i am trying to achieve. First image is with Preserve Aspect while the second one is without it.
What should i do to achieve it.
Thank you.
This is one way to do it that I can think of, using 2 images. The outer image is set at your desired size and have a Mask component:
The inner image is set at center of the outer image and scaled to fit the outer image (either programatically or by hand) It will be cropped by the outer image's mask and only display the area you want.

How to make an image draggable inside Imageview?

Is this possible, have anyone done anything close to this? I saw this behaviour in an ios app and need to reproduce it, basically the image is full size on the X axis and it can move up and down through the Y axis inside an Imageview, I tried doing this with an Imageview inside a FrameLayout without success, the Image is always cropped to the max size of the Imageview which is relative to its parent (FrameLayout). Any help is welcome.
I guess you could just write your own class. Intercept the touch events, monitor the vertical offset and redraw the image with this vertical offset.

Android: make the size of a custom view bigger than the size of screen

enter image description hereI have a custom view and the user can draw rectangles(I used canvas). I would make the size of custom view bigger than the size of the screen. So, the user can draw not only in the size of screen. I tried ScrollView and NestedScrollView but they are not helpful to solve my problem.
As far as I could understand from this question is you want to make a canvas where someone can draw some pictures. So you need a bigger canvas to that user can drag the positions to left-right, up and down. If I understood correctly, then I would say, you might think of a different work-around instead of looking for a view bigger than the screen size.
You can think of an simple ImageView which will be auto zoomed-in and if the user clicks twice it'll zoom-out. The user can drag the positions of the ImageView whenever he wants.
Here's an SO answer about how you can implement the zoom in and out in an ImageView. Hope this will help to solve your problem.

Resize an image whithout scaling it

I'm trying to resize a viewGroup from the right to the left. Inside my viewgroup I have some images. I tried to put all the scaletype values. The problem is that my images are getting scaled. I want them not too move.
What I want is basically resize my view and not see the image being scaled. Like if the view was hide by something going in front of it. I'm doing an animation so the goal is suposed to simulate a hidding motion. Like a truck passing in front of a car, the car is not scaled, just hide. The car is my view and the truck the width. I don't want to hide it with another view in front of it by making a translation. If possible i don't want to touch to my images, I already put the centerCrop value, but if you have a solution with it, share it please lol.
I don't have the code under my hands right now so I can't show you, but if you have any idea, thanks to share ;).

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.

Categories

Resources