Load image if required in list view? - android

I have a row layout with
image
title which gets inflated on a list view.
The problem is the image should be of size 80dp x 80dp where there is no guarantee as the image may be null in the DB. So I would like to know how we could check wether for the availability of the image in the db.If it is available then inflate the image aligned left with the size 80dp x 80dp in the row layout that is inflated for a list view. Elhe nse don't display the image. (Using Picasso to load images over the network)...

In picasso there is a method called error.Then if the url is wrong then the image in the error is loaded.You should only check if the image path is null by checking the string.

Related

Glide: Resize ImageView to fit image in glide, not the other way around

I have a recycler view where cells contain an ImageView. I'd like the cells to match_parent width (the screen width), but expand height wise as needed and keep aspect ratio (wrap_content). The problem is that Glide will resize the image to match the placeholder image or (when reusing a cell) match whichever the previous image size was. Is there a way I can tell Glide to get the native image size, every time? I don't want the image to resize, I want the imageview to resize.

How to position a View in Android to match space in background

I have a layout where I have to take an ImageView, and position it somewhere relative to something in the background image. For instance, the ImageView would be of an item, and on the background image there would be a shelf, and I would need to position the ImageView such that the item looks like it is on the shelf. Another example would be of a frame in the background, and I would need to position the image so it looks like it is in the frame. This needs to account for scaling. I do not need it to work through rotation, as there are different layouts for portrait and landscape.
One way would be to associate the relative position of these items with the background images themselves. For instance, the height of the position of the top of the table is at x% of the total height of the image. Then, when it scales, it's now at x% of the current height.

Android: Repositioning ImageView

i have 2 imageview. first one for containing the image and the other one as the frame.
i already set image position to have the same position as the frame after loading the image.
i also already check the value and its the same.
but somehow the image position is not the same as the frame when i try changing picture with 2 different size (width x height).
ivProfilePicture.setX(ivFrame.getX());
ivProfilePicture.setY(ivFrame.getY());
by the way, i use custom imageview for the image container, i only custom the function onMeasure. there's no image repositioning.

How can i change row height of a GridView at runtime

Is there a way to change row height of a GridView? I need to do this via code (not xml). I get some images from a webservice to create the gridView. Row height must match the height of the first image i get.
I need to do the same with the width, but i saw that there's a method called "setColumnWidth". Can't find something similar for the row height.

Use image sizes

Is there a way to use an image size when setting the sizes of a view? I want to create a TextView item with the exact height of a resource image, but I don't want to use the image as a background for the text view.
If you can get the height of the image, you can use TextView's setHeight. If you read in the image as a Bitmap, you can get the image's height with getHeight.

Categories

Resources