In my app I am getting image from URL and showing in an ImageView. I get a circle shape(blue color) image which is in a square(white color) background. I want to show my image just as a circle ..How to remove or hide the extra white color in that image within my app?
Below is the image for reference:
You should first remove the white part of image in an image editor like Photoshop or Gimp. Making background transparent won't work because white part is not background, It's in image.
Alternatively, You can create a round Imageview if you want your square images to be shown as circular (e.g. profile pictures on Google+). There is a working code snippet here for rounded ImageView How to create a circular ImageView in Android?
Alternatively, if you don't want to use this snippet, you can use a library that will make it easy to create rounded ImageViews. see this
https://github.com/vinc3m1/RoundedImageViewā€ˇ
Related
I'm getting an image URL from JSON, I set it in ImageView by using the picasso library.
However, I'm facing one problem: the image I am getting from the URL does not have a transparent background.
How do I make it transparent and then set it to ImageView?
LOL,
For this,
Your image needs to be transparent.
You can only make background of ImageView transparent not image in Android.
This question already has answers here:
Crop square image to circle - Programmatically
(7 answers)
Closed 7 years ago.
hey guys so I'm trying to make this circle button. And in that circle I want to put an image, like a person's profile picture. So if someone uploads an image, I need to be able to adjust the size and crop it and put it into a circle. Below is an example of what I am trying to accomplish. And behind the circle is a red circle, just for aesthetics. Hope you guys can give me some insight or direction.
You can do this easily by using ImageView two properties: background and src
Get a square image with transparent circle
Set step 1 image to the src property of an ImageView
Set the background of your ImageView with your avatar photo (square).
Please see here for the static avatar image solution:
ImageView in circular through xml
If your avatar is dynamic, then you need to set the background image dynamically and this post will help:
Changing image view background dynamically
If you are using Picaso then use this:
android: create circular image with picasso
However it has great performance concerns.
I want to crop selected image in circular shape from gallery. I have checked few solution for same question, but I am not able to solve my issue. Maximum solution provide for custom shape imageview means provide a .xml file or class extends with Imageview but I want to crop image like following screenshot or Instagram app crop image.
If you do not mind to use a library.Use SimpleCropView library,it has circle crop mode.
https://github.com/IsseiAoki/SimpleCropView
so I'm trying to find the region of the current image in the ImageView and fill that region with a different image. Here is the original image Empty Circle inside an imageView. The imageView has a drawable of a circle inside. Then I'm trying to make it into something like this Circle filled with image inside an ImageView when a user chooses an image. I don't want to manually Photoshop a circle image. I am just hoping to fill the region with another image. I have tried SRC_IN method from AlphaComposite, but for android, I can't convert from BitMap to graphics2D. If anyone knows how to solve this using the BitmapFactory in android, I would really appreciate your help. Thank you.
The other solution besides Bitmaps, may be too simple for whatever you are trying to achieve otherwise I think it would have occurred to you. I'm just pointing it out in case you have "code blindness" and are trying to over-engineer the solution because you've worked on it for too long (we've all done it)
It is to have that circle/shape image saved as a png with the area you want filled being transparent then set it as the drawable for an ImageView (etc.) then in a RelativeLayout lay this view over the image you want to fill the area and apply a transparent background to the shape view OR simply set the fill image as the background for the shape view.
I am doing a project in which i want to fade my background image from normal to fade the same image so the text over it can be displayed properly...but i am not getting how to do it??
Try putting both images in a TransitionDrawable. This is a type of drawable that is used to cross-fade between its layers when startTransition(int) is called. See the TransitionDrawable documentation here.