I need to set the height of an imageview as matchparent programatically.if it is a fixed height i know how to set.
but how can i set it as matchparent?
EDIT:
actually height of the parent layout is dynamic.so i need to make the height of the imageview as the height of parent.
If you want to just fit the image in image view you can use" wrap content" in height and width property with scale-type but if you want to set manually you have to use LayoutParams. Layoutparams is efficient for setting the layout height and width programmatically.
This example demonstrates how to resize Image in an Android App using Kotlin. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.
imageView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
imageView.getLayoutParams().height= ViewGroup.LayoutParams.MATCH_PARENT;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With