I have an image which is actually 393 x 21 px, which I would like to set on the bottom of my View.
The problem is that, even if i set the width and the height to fill_parent, my image stays very small in the middle of the screen bottom and on the left and the right I have an empty field.
I can resolve this by reducing the Image width size mannualy but is ther any other solution whic could set the image in fullscreen ?
Thank you.
//in your xml Image attribute as
android:scaleType="fitXY"
or //using thru programatically
imgview.setScaleType(ScaleType.FIT_XY);
Related
Things looked quite simple first but in the end the result is not good.
I have an image which has a width larger than screen's width. So I need to scale it down in my imageview. I looked over the ScaleType options and tried them all but none is ok. First "center" only displays the image centered on the layout, no scaling done. "fitCenter" scales the image to fit in my layout but has a major drawback: the height of the item remains as it would have the large image in it. Take a look at the second screen in the attached image. How can I force the list item, to reduce its height to wrap both the text and the image ?
Use the scaletype which seems best to you ( I guess you like what you see with fitCenter). The additional thing that you must do is
android:adjustViewBounds="true"
in your ImageView.
or you could go with FitXY but sometimes the result is not exactly what you want.
use android:scaleType="fitXY"
Could you use FitXY?
This would work if you knew the size of the area you were putting the image into.
CentreInside may also work, I've used this to scale down images, but I think it depends if you've control of the size of the bounding layout element.
You either need to set android:height = "wrap_content" on your outer container, or set static height of TextBox and give ImageView android:weight = "1" so that the ImageView takes remaining space in container.
I am developing application having a resemblance appearance like " Gallery application".
When I click on image from the gallery... I want to fit image to whole screen..
I used this code..but it does not work .
can you guide me for this ...
Here is code for the same:
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
imgView.setMinimumWidth(width);
imgView.setMinimumHeight(height);
imgView.setMaxWidth(width);
imgView.setMaxHeight(height);
you should use the following attribute of the imageview to fit the image to the screen.
Controls how the image should be resized or moved to match the size of this ImageView.
Must be one of the following constant values.
Constant Value
matrix 0
fitXY 1
fitStart 2
fitCenter 3
fitEnd 4
center 5
centerCrop 6
centerInside 7
android:scaleType="fitxy"
like wise you can use others to change the size of your image.
You may consider having the image open in its own activity, with android:noHistory="true" in the manifest, and onClick() have it end the activity. That way you don't have to worry about the image resizing and ruining everything in the activity it is being chosen in.
I am using google graph to get the desired graph for me and display it on a android device.
Now I want to display the received graph on a tablet screen but google graph api supports only 300,000 pixels as a max size (width x height) graph.
I am making a request for 500 x 600 px image and display it on a ImageView. I set the scaleType to fitXy and give the imageView width=fill_parrent height=850dpi because I want the image to almost fill the screen.
The problem is that the background of the image goes light gray or blurring after the ImageView scales the image and it looks bad on the white background of my application... If I make the ImageView wrap_content on width and height the graph has white background.
Is there any way to get the image displayed without changing it's background color?
Please note that I don't want to change the image's size.
I'd recommend to instead use width match_parent and then setAdjustViewBounds=true
If that doesn't fix it you probarbly have to change the image.
Unfortunately I had to change the image to a bigger one and the problem disappeared.
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.
I have one question. I want to set one image to image button. I have one button image of size 90 x 48. I want to set this image on Image button.
Problems:
I need to set image on background parameter or src parameter?
If i set image on background parameter its not showing its actual size(smaller than actual size) if i have set the Layout width = wrap content and Layout Height= wrap content. If i give Layout width = 98dip and Layout Height= 48dip then its showing the same size. Is it a coorect way?
thanks
set image as background Parameter sometimes src makes problem
if you are set width and height as wrap_content then android will check the screen size and try to adjust to your screen if screen size is big then android displays your image as its actual height and width and if screen size is less then it will compress your image
so best way is to set height and width is as wrap_content if you have to use portrait and landscape mode both
Yes.
If you use Layout width = wrap content and Layout Height= wrap content, image will be as actual size. Maybe just the density of your monitor is less than the density of your phone?
Remember dip != pixels.