Code example for ImageView

Methods: layoutmeasuresetLayoutParams

	 * This will make sure the view falls back to the ViewParams/Max/Or Config if wrap content so that it is never 
	 * shrunk to the first image size. In this case it falls back to the config size 
	 * @throws Exception 
	public void testGetImageSizeScaleTo_dontUseImageActualSizeWithWrapContent() throws Exception { 
		//Set it to wrap content so that it will fall back to 
		mView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
		mView.measure(View.MeasureSpec.makeMeasureSpec(250, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(250, View.MeasureSpec.EXACTLY));
		// We layout the view to give it a width and height 
		mView.layout(0, 0, 200, 200);
		ImageSize expected = new ImageSize(500, 500);
		ImageSize result = ImageSizeUtils.defineTargetSizeForView(mImageAware, new ImageSize(500, 500));
Experience pair programming with AI  Get Codota for Java