I'm new to Android Java programming. For a project I need transparent images, which change dynamically. I have created a layout with an ImageView. And in it a small GIF USA flag GIF with a transparent background.
In code I connect the variable to the imageview and assign the same image to the variable from the ImageResources
ImageView image = (ImageView)convertView.findViewById(R.id.listview_image);
image.setImageResource(R.drawable.vlag);
This goes pretty well however the image is displayed with a white background. The transparency is lost. This is shown in the image below by the white background.
GIF over ImageView are always an issue. Use GIFImageView
And you must use it this way:
gifImageView = (GifImageView) findViewById(R.id.gifImageView);
gifImageView.setBytes(bytes);
gifImageView.startAnimation();
Even it has an option to download the gif from the web.
Related
I'm using this library for SVG image rendering. The library itself is unable to change the Picture opacity and color. There is an issue tracking this, but I'd like to work around this in my code.
I'm getting SVG image data my API and storing the files in a local directory. I then load the SVG into an ImageView as follows:
Sharp.loadFile(new File(StickerList.get(position).get_thumbnail_url()))
.into(holder.nuggetImageView);
This approach using loadFile().into() loads my SVG image into an ImageView, as expected. However, I'm not successful in changing the image color and opacity change. I've tried doing this as follows:
ImageView imageView = imageRootView.findViewById(R.id.photo_editor_sdk_image_iv);
imageView.setColorFilter(colorFilter);
imageView.setAlpha(alpha);
This appears to have no effect at all. What would be a way of changing the color and opacity?
Graphic designer who I work with provided full-screen splash screen image. I was asked to use it in a way, that it works as if it was ImageView with scaleType set to centerCrop. I also was asked to show this image immedietely when app starts.
So, I tried to set application splash screen via windowBackground attribute, but it's stretched as if scaletype was fitXY (in ImageView terminology). People all over internet use that, or use drawable resource with app icon centered and background set to certain color, as described in this article: https://android.jlelse.eu/the-complete-android-splash-screen-guide-c7db82bce565
So my question is - Is it possible to achieve centerCrop behaviour when using windowBackground, so it works as below:
(Original provided fullscreen image on the left. Black border indicates device resolution)
Note I can't use activity layout for splash screen.
I'm trying to take a screenshot with Robot and view it in an ImageView, The problem is the screenshot coordinates is the ImageView Global coordinates.
So basically I'm trying to capture what's behind the Imageview but instead I get a picture of the Imageview itself.
I can't minimize because I'm taking several continuous screenshots that may vary in resolution.
What can I do?
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'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.