How to resize a ScrollView - android

I have a ScaleDetector in which I zom in my ImageView when it detect a scale movement.
This works, the image is well scaled.
But the problems is that my ImageView is in a ScrollView, and the ScrollView doesn't resized itself when I scale. So when my imageView is scaled, I can move on it in the first limits of my ScrollView, not beyond.
And of course, the SrollView doestn't have an "setMatrix" or something like that which could allow me to easilly resized it.
So how can I do to resize my ScrollView ?

First solution I can think of is, in your java code insert :
scroller = (ScrollView) this.findViewById(R.id.scroller);
scroller.setLayoutParams(new LinearLayout.LayoutParams(width, height));
Then adjust width and height according to your scale.

Related

Android scale a RelativeLayout with an ImageView inside

I have a RelativeLayout with an ImageView (with match_parent as height and width). The ImageView has a scaleType of center_crop.
I programatically scale the RelativeLayout in the Y axis according to a specific gesture on the device. The RelativeLayout scales correctly, but the ImageView stretches instead of center_crops as expected. I assume this is because the ImageView is only centered and cropped in the start during the layout process. Is there anyway I can force the ImageView to recalculate the center_cropping process while the gesture is in motion?
I will appreciate any help. I can post more information and examples if my question isn't making any sense.

Multiple imageview on touch action listener

I have 4 views in the same activity. I want to move each Imageview on touch in whole screen, but it allow me to move in its width height.
Each image view's layout height and width is wrap_content.
It works fine with one image view with fill_parent.
Its explained in this example.

Bitmap ImageView, inside a HorizontalScrollView. How to fit the HorizontalScrollView Height with the bitmap?

I have a Horizontal Scroll View, and inside it i have a ImageView. This imageview has a Bitmap with high width and low height.
I want the bitmap to fill the height of the horizontal scrollview, and I want to scroll the bitmap from left to right.
I tried to use this code, but it doesn't work. It creates two spaces on left and right, these spaces are black. These spaces are from the ImageView... so... the bitmap has less width than the ImageView
HorizontalScrollView wvScroll = new HorizontalScrollView(this);
wvScroll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
iv.setImageBitmap(Util.getRemoteImage("http://mywebsite.com/90.gif"));
//iv.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
iv.setScaleType(ScaleType.CENTER_INSIDE);
iv.setBackgroundColor(Color.BLACK);
wvScroll.addView(iv);
wvScroll.setBackgroundColor(Color.GREEN);
mainLayout.addView(wvScroll);
what am i doing wrong? I also tryed with iv.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); but it doesn't works, Same result.
EDIT:
I also tryed with ScaleType.CENTER_CROP and it doesn't works fine. The bitmap has higher height than the ImageView, because some pixels lost on top and bottom of the bitmap.
If I had to approach this in the simplest way. I'd set the width of the scroll view the same as the screen width. The height doesn't matter as much because you're assuming the height will fit in the screen(At least that's what I gather from your question).
From what I remember scroll-views will scroll anything bigger than than the actual screen or anything that is bigger than the specified scroll-width or scroll-height its given.
This might help you get started with getting the respectable screen sizes - Get Screen width and height
Of course since different devices have different screen sizes - you'd have to do this "pro-grammatically".
Would this sort of implementation work for you?

Add ImageView in RelativeLayout with coordinates

How to add ImageView in RelativeLayout with some coordinates, which is bigger than RelativeLayout Size?
Trouble is, when I add ImageView with padding left bigger then layout width, and use in that layout scrollTo(-100,0) (for example), I can't see nothing, my ImageView disappeared, or be smaller(when padding left a little less than layout width).
How can I turn off ImageView auto-scaling or something?

android ImageView/ RelativeLayout increase size by Dragging the corner of ImageView/ RelativeLayout

i want to increase the size of ImageView/ RelativeLayout by Dragging the corner of ImageView/ RelativeLayout. But no difference in width and set it bottom. I set it by using android:layout_alignParentBottom="true" and also set image in imageview. but how to drag i don't know. Is there is any option available in Android? can any one suggest some solution for this? pls help me
you can use onTouch() for the ImageView.
Once it is touched show a small image at the edge of the imageview. And on touching that image and moving(onTouch() gives the pixel positions until you touch it) you will be getting the pixel positions. Based on that you can set the height and width of the imageview.

Categories

Resources