-
I have a ListView and each row has an ImageView.
-
These Images are downloaded in a separate thread and then appended to the ImageViews in the UI thread.
-
The images I am downloading are 92 X 136 px. I am scaling these images down to 50 X 100 px each using the BitmapFactory.
-
I want these images to look the same size across different screensizes.I understand that on a screen with higher density these images can look smaller and on those with lower density they can look bigger.
-
Normally we would put such images in mdpi,hdpi etc folders , but in this case the images are beig downloaded dynamically and scaled programatically.
Can someone point me in the right direction as to what I should do. I dont need any codes.. just some algo should do…
I have a ListView and each row has an ImageView. These Images are downloaded
Share
One way is to scale in DP like this:
The other way is to hardcode the dimensions on the imageView in dp or assign its height width programaticaly after getting the screen metrics and calculating some percentage of the width/height to fill(although i think using just the fixed dp in the layout will be sufficient, if needed you can use values/dimensions to mark the size of the view). And assign a scaleType like
fitXYorcenterCropto the imageView to fill the whole content area.