I am facing problem on removing image from ImageView.
What I want an Image is loaded in ImageView, and then a new Image is taken by the camera and now that Image should load in ImageView replacing the previous one. I have tried
invalidate();
setImageBitmap(null);
setImageResource(0);
All these 3 methods are not working. Can someone help me.
Use this for setting image in ImageView
image.setImageResource(R.drawable.image);
If you want to set the Image By Drawable Image you can use like this
your_image_view.setImageDrawable(context.getResources().getDrawable(your_drawable_Image_id));
If you want to set the image by BitMapDrawable
your_image_view.setBackgroundDrawable(your_drawable_bitmap);
edit_countflag.setBackgroundColor(0);
edit_countflag.setImageResource(R.drawable.flag_id);
Related
here's my problem... Would it be possible to load a picture, call the crop activity, and load the cropped images on different imageviews without changing the main image??
I have 3 imageviews. My imageview 1 is for the main image loadout, my imageview 2 is for the result of the crop activity, the same goes with imageview 3.
I am using com.theartofdev.edmodo:android-image-cropper:2.6.0....
The good thing about this one is that it already has lots of functions, but the problem is that what I want to happen is that it would load the image that I have already called in my main imageview.
Get the instances of the Views in the activity class.
Use the method below to get the image source to bitmap
Display bm returned from convertImageViewToBitmap to the second ImageView.
private Bitmap convertImageViewToBitmap(ImageView v){
Bitmap bm =
((BitmapDrawable)v.getDrawable()).getBitmap();
return bm;
}
For example, if I loaded an image into an ImageView as such:
Imeteor = (ImageView) findViewById(R.id.meteor1);
Picasso.with(this)
.load(R.drawable.red_meteor)
.resize((int) meteorWidth, (int) meteorHeight)
.into(Imeteor);
Is it then possible to translate (move across or around the screen) said ImageView using Picasso? The current method I am using is below.
Imeteor = (ImageView) findViewById(R.id.meteor1);
Imeteor.setX(meteorXPosition);
Imeteor.setY(meteorYPosition);
With the values of "meteorXPosition", and "meteorYPosition" being updated in a separate method from where the image is loaded. Also, "meteorXPosition", and "meteorYPosition" are updated every millisecond.
Or,
By the fact that the image is loaded using Picasso, does that mean that the every time the ImageView is accessed it is accessed through Picasso? For example, by the code I provided above
Imeteor = (ImageView) findViewById(R.id.meteor1);
Imeteor.setX(meteorXPosition);
Imeteor.setY(meteorYPosition);
For anyone who might read this, and doesn't bother to read the comments. Picasso only handles loading the bitmap, and performing transformations on the bitmap in the image view. For moving a bitmap within an image view an option is to use the image view's setX() and setY() function. Which moves the the image view to a new location (the bitmap is in the image view). For moving images it is best to look up how to move an image view.
This situation I have met in Android and still can't find any solution.
I have an ImageView display by these code:
BitmapDrawable value = ...;
imageView1.setImageDrawable(value);
Then I use imageView2 to display the same image in Drawable:
imageView2.setImageDrawable(value);
And ops,... the image in imageView1 auto scale and become bigger than the older. (imageView2 is bigger than imageView1).
Is there anyone saw this situation before?
Drawables are immutable, so the one bitmap is getting scaled and then shown by both ImageViews.
To get a different (unshared) version for the second one, try:
imageView2.setImageDrawable(value.mutate());
I'm using Picasso for downloading images from URL and putting in ImageView. Images are rectangle, but my ImageViews are squares. So I need to use some cropping, because I have spaces on top and bottom.
Without cropping the image is clear:
Picasso.with(context)
.load(left.get(pos).getImageName())
.into(ivFrontPageLeftImage);
To fit inside and crop I'm using:
Picasso.with(context)
.load(left.get(pos)
.getImageName())
.fit().centerInside()
.into(ivFrontPageLeftImage);
But as you can see the image is not clear, it is blur.
So how can I fit image inside the square (ImageView). Also image need to be clear, not blur?
I download this image, crop it with size 300 x 300 (to be square, i cut from left and right) and upload it. I use this new image to put in ImageView:
Picasso.with(context)
.load("http://oi62.tinypic.com/29y61p3.jpg")
.fit().centerCrop()
.into(ivFrontPageLeftImage);
As you can see image is clear and it is not blur.
How can I do this programmatically? Is it possible with Picasso, or I need other library to do this?
I can't comment on Lee's answer as I don't have enough reputation. But his answer was correct as I had the same issue. You can also set it in the ImageView object by doing the following:
imageView = (ImageView) view.findViewById(R.id.img);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
Apply center crop on your ImageView instead of the method you are now using.
<ImageView
...
android:scaleType="centerCrop"/>
i am working on displaying an image and placing an icon on top of it... clicking the icon will show an enlarged version of the image...
though putting the imageview holding the image in a LinearLayout scales the image to the width of the dialog, the problem is that i need to display the image in a dialog but the image is very high resolution and hence is far bigger than the width of the dialog...
I need to show the actual image with scrolling for both ways to see the whole image... But whenever i try putting the imageView in a scrollview the top of my imageview is blank... and again though image scrolls downwards the width is scaled to the width of the dialog...
Helppppppppp guys....
Thanx for your help androidbase... I found the solution... Actually we can say its a workaround but better than any other solution i can think of...
Actually what i do is that i implement webview and directly load the image url in it using webview.loadurl(myurl);
and further i enabled the zoom featured too hence i get an allround complete zooming capabilities...
Thanx all 4 ur help
developer.android.com/reference/android/graphics/Bitmap.html
developer.android.com/reference/android/graphics/BitmapFactory.html
refer this link.
Bitmap mIcon1 = BitmapFactory.decodeResource(context.getResources(),R.drawable.twitter_icon);
imgview.setImageBitmap(mIcon1);
convert your image to bitmap and use. hope it works.....
EDIT:
URL img_value = new URL(string_url_input);
if (profile != null) {
Bitmap mIcon1 = BitmapFactory.decodeStream(img_value.openConnection().getInputStream());
image_view.setImageBitmap(mIcon1);
}