I have the following image that I intend to use in a game:
When I use "Add new Image Asset" and add this image as a "Action Bar and Tab Icon"
All the black parts of the image are replaced with white so the image looks like this when it is drawn on the canvas:
Why is the image getting destroyed and how do I fix it?
I thought about putting the image as a "Launcher Icon" but that didn't seem to make sense.
Use Scaletype property in ImageView which helps you to manage the image inside ImageView.
Related
I am using the Eclipse drag 'n drop feature to add a PNG image to my app UI.
When I drag the ImageView widget from the menu into the UI area it asks me to select the image from a list. I have named the picture image1 and when I select it there is just a placeholder image (a red cube with Aa in).
I have tried re-sizing the image and using different images. The placeholder image is visible on my UI but nothing I have tried can made the actual picture I have put in my xhdpi folder show up on the screen.
Any help much appreciated.
I'm not entirely sure why but when I changed the filename from image1.png to image2.png it worked.
The placeholder image that I kept seeing was listed higher up in the hierarchy as image1-web.png so I wonder if that was taking precedence.
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ā€ˇ
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 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.
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.