I'm using fresco to display images in a list view. however i have an issue.
when i scale my image using methods that maintain aspect ratio like CENTER_CROP, and the scaled image height becomes smaller than my simpledraweeview's height, simple-Drawee-View isn't automatically resized to match size of scaled image.
- I have tried to use
android:adjustViewBounds = true
But it doesn't work. i have also tried the method below but scaleY which i wanted to use to calculate scaled height returns 1 even when image height is smaller than simpe-drawee-view's height
float[] f = new float[9] draweeView.getImageMatrix().getValues(f); float scaleY = f[Matrix.MSCALE_Y]; Log.d("App","scale y is "+ scaleY);
The above codlet is used in the method below
private void loadImage(Uri fileUri,final SimpleDraweeView draweeView,int myImageHeight){
draweeView.getLayoutParams().width = displayWidth;
int selectedSize = (myImageHeight > displayWidth)? displayWidth : myImageHeight;
draweeView.getLayoutParams().height= selectedSize;
GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(context.getResources());
GenericDraweeHierarchy hierarchy = builder
.setProgressBarImage(new CircleProgressBarDrawable())
.setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP)
.build();
ImageRequest requestBuilder = ImageRequestBuilder.newBuilderWithSource(fileUri)
.setProgressiveRenderingEnabled(true)
.build();
//ImagePipeline imagePipeline = Fresco.getImagePipeline();
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setOldController(draweeView.getController())
.setImageRequest(requestBuilder)
.build();
draweeView.setHierarchy(hierarchy);
draweeView.setController(controller);
float[] f = new float[9]
draweeView.getImageMatrix().getValues(f);
float scaleY = f[Matrix.MSCALE_Y];
Log.d("App","scale y is "+ scaleY);
}
RESULTS: red color symbolizes parts of simple drawee view not filled with the image. this is Scale type FIT_CENTER. when i use CENTER_CROP, the image fills the entire imageview and some parts of the image are chopped off and i don't want that
Q: How can i get scaled image size and use it to resize my simpleDraweeView or in other words, how can i make my simpleDraweeView adjust it size ?
i will appreciate any help.