Setting a transparent background to an image - android

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.

Related

Remove transparent white background from gif image using glide?

How can I remove white background around image when loading with glide.. You can find out below code as well as screenshot;
Glide.with(thiscontext).load(R.drawable.badge_green_yellow)
.asGif().crossFade()
.diskCacheStrategy(DiskCacheStrategy.SOURCE).into(holder.ivHourlyIcon);
ScreenShot
Put your GIF into the raw folder (res/raw/badge_green_yellow.gif)
and then load it like this
Glide.with(thiscontext).asGif().load(R.raw.badge_green_yellow).into(holder.ivHourlyIcon);

How to modify image appearance in Image View?

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ā€ˇ

How to fill the drawable region in an imageView with another drawable?

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.

set new Image on ImageView

I created an XML layout for my project with an ImageView in it. I add a default image for imageView. Now programatically I am getting that imageview and trying to change the image source using imgView.setImageBitmap(newbitmap);.
The problem is that both images are showing - the default image displays behind programatically added one.
I tried:
imgView.setImageResource(0);
imgView.setImageDrawable(null);
imgView.setAlpha(0);
imgView.setImageBitmap(null);
...but the default image is still visible.
If you are setting the background of the ImageView in the xml file, then it will remain until you clear the background. ImageView is odd in that it can display two images, background and source. Use the attribute android:src to set the source image and 'android:background' to set the background. All the methods you described will replace the source image but keep the background unchanged.

Fading background image from normal image to faded image

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.

Categories

Resources