Android:How to get the name of the background image of ImageView - android

Is there any way to get the background image name of the ImageView.
Appreciate your time.
Thanks

No, because the background image does not necessarily have a name. If you are the one setting the background image, you would need to keep track of the name yourself.

Related

I can't make an image transparent on Android?

I tried everything, but it didn't work. Please help me
All you have to do it to download a transparent img of a cart and adjust the width and length you can also download it with the link below 👇👇
https://www.flaticon.com/free-icon/shopping-cart_833314?term=cart&page=1&position=3&page=1&position=3&related_id=833314&origin=search
If you have taken this image from your storage then you can simply convert it's background transparent by using any background remover tool online such as this one:
remove background

How to reset the resource of image view in android?

Trying to change the image in imageView dynamically based on the status.
Image changed successfully but problem is walk image overwrite on the run image. I want to clear the existing image and then set the new image.
status_image.setImageResource(if(runningState == RunningState.FAST) R.drawable.ic_run_fast else R.drawable.ic_walk)
Just call it with a "0" parameter before doing anything else:
status_image.setImageResource(0)
Nullability of drawable content is your friend, AndroidDocs nailed it: setImageDrawable
So in your case statusImageView.setImageDrawable(null)
Try to set the ImageView to transparent. Then change it back to the resource you want.
status_image.setImageResource(android.R.color.transparent)
Another option is to use some third party lib to handle the images for you as well, like Glide, Fresco, or Picasso.

What's the reverse of : SetBackgroundResouce?

As the question suggest, SetBackgroundResource is used if you want to set the background of an image button according to an image, such as:
p1Cards[n].SetBackgroundResource(Resource.Drawable.b1fv);
where b1fv is the image file.
Therefore my question is, what is the appropriate command to get the background image? For example, if I want to check whether an imagebutton is using this certain background image, what is the command to use and check?

How to get the name of drawable through resource id?

I am trying to make the bitmap and for this I need the drawable name such as:
overlayScaledBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.monkey);
This is working fine But my problem is that I can not do this same thing when a user selects a picture from a list because I have done this statically. As you can see I have wrote R.drawable.monkey. So its means every time it is going to create bitmap with monkey image.
But it is not the case, the user selects image which gets fixed into the image view. Now I want to get the ImageView as drawable. If it is possible then it could be dynamically and would be easy to handle. Any idea How I can get drawable of ImageView to use in bitmap scaling? please help
You could create an enum object containing all refs to the bitmaps and an id.
But another way is using getTag() and setTag() on the resources to identify by.

Is imageview needed within this imageview?

I use an ImageView to display the entire image. I want to launch the next activity when the sun is touched. Is it possible by using this single image or should i use separate imageview for sun? I know how to do it with separate imageview. I want to know whether it is possible by using only the full image?
Use two imageviews
Easier and less bug-prone

Categories

Resources