I'm getting stuck at a certain part of my app.
In my app, I have a few icons. The icons are completely white with transparent backgrounds. Is it possible for the user to set the colour of the icons without messing up the transparency? I tried searching a lot, but couldn't come up with anything. Could someone help me out?
Also would it be possible for the user to set custom icons from any folder as per their choice?
Thanks.
Yes it's possible. You have to create bitmap from resource How to set a bitmap from resource, then search bitmap for white pixels and change them to desired color (pix - by pix), then just set result bitmap as button or other layout element bitmap.
Related
hi.
I have a problem with android layout.
gif is what designer want I make. and I made things successfully but menu.
png(alpha image) is our menu image. last 40px of height is want to display.
and if user touch that 40px of image is coming down just like gif image shows.
I don't have any idea how can make that. Constraint Layout doesn't support negative value.
ps. png is based on 1080 height resolution. but I will add dynamic resolution calcaulator function, so don't mind about 40px. 40 just mean 'want to display part of imageview'
SOLVED.
make imageview in constraint layout xml and inflate it.
then you can set x,y location programmatically.
I confused it. because when I tried it, It doesn't work. you must know view has relative location.
I am trying to add an image to another image so that I can crop out what I do not want (all the black areas). I have implemented the camera in my app in an android studio and am saving files to my android device. I don't know how to do this.
I have an image view over the camera so that they can get the "shirt" inside the "outline" so it will be easier to crop once I overlay the image and bitmask out all the black. Black Cookie cutter, Original shirt , Both images overlayed, and the final would be just the shirt and nothing else around it as a png so the surroundings are transparent so that I can load it from my specified file directory onto a mannequin like this: Final output.
Any guidance would be helpful. Also sorry I could not embed the pictures as I am new to the site and it only let me post links that are from this website, so they are safe!
To set an overlay over a 'saved' (captured) image, your major concern is that the uncompressed image may get huge. I would use partial images only, and a scaled down version for on-screen preview (if you want to let the user to manually fit the shirt). For the latter task, you can use a png with reduced resolution (even less than 900x1200) and transparency: this way you can use two ImageViews.
If you want to match the shirt overlay on top of a live preview coming from the camera, I recommend to load the shirt in a separate texture, and use OpenGL to display the live texture coming from the camera and the shirt RGBA texture 'above' it. Setup of transparent pixels in this case may be handled in a custom shader.
I have ImageView in my application, but images in this ImageView have white background. How I can delete this ColorDrawable. I need to replace White to Transparent. How I can do it programmaticaly?
This is probably not as easy to do programmaticaly but it is easy to do in an image editor. I always do it in paint.net. You can download it here: http://www.getpaint.net/download.html
This youtube video describes how to do it: https://youtu.be/cdFpS-AvNCE
It literally takes less than a minute to do and is what I have used on a lot of my projects.
The color you set by ImageView.setBackgroundColor method shows up only where the src image have some transparent pixels or some spaces of ImageView that is not covered by the src image because of scaleType And I'm not sure you want to process images in your code in order to replace back color with transparent color, So the right way to achieve that is to use some Photo Editor softwares to edit images before using in your app.
First, you'll have to remove the background from the original photo using a photo editor like GIMP ,be sure to save the file in an Android supported format that supports transparency (PNG).
Next, inside the XML layout file (or in code), put the drawable view itself inside a FrameLayout.
Finally, call View.setBackgroundColor() on your FrameLayout.
I want to have an image on the android screen where different parts of the image can be clickable. What I mean is that, If its an image of 3 circles, I want to be able to click each of these circles,
Then I can add different functionalities to each of these clickable circles.
For an instance in this image below I want to be able to click each distinct color. Is it possible to have on-touch-listener and get you the color ? and can it be an image or has to be drawn in Java OR XML ?
I found a really good widget that helps you make any image muli-clickable. They have some good notes on how to use their widget as well.
The widget has a similar approach as Image mapping in html. The good thing about this widget is that the image can be zoomed and it will not lose the coordinates or areas associated to specific clicks.
Here is the link to their website. the guy who made the widget apparently had similar problem and came up with this widget.
Another solution would have been
creating an ImageView containing the png file referenced
making the whole ImageView clickable
setting an OnTouchListener to the ImageView which overrides the onTouch method
check the colors of the image pixel at the touch position
This is often done with an invisible mask image with one color for each zone (see the popular detailed tutorial), but here the image itself has distinct colors for each zone which makes it more interesting.
I need to create different image size with green color in microedition, is it possible?
I need to create the image on the fly without loading an image.
Here you go,
http://www.java2s.com/Code/Java/2D-Graphics-GUI/DrawanImageandsavetopng.htm
change the color from black to green in example.
If you want images to be unique draw unique numbers instead of text.
if you don't want to use text in the image then simply draw something but start the drawing at a random location in the image.
Out of curiosity are you trying to test the servlet or the phone app?
Sorry earlier I missed that you wanted to achieve this in J2ME
See the link below
http://www.java2s.com/Code/Java/J2ME/MutableImageExample.htm