I have done this in the past and I am frustrated because this method is not working like I expect it to. I have an image that I want to resize to specific dimensions and I am using the code below:
snellen.post(new Runnable() {
@Override
public void run() {
ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) snellen.getLayoutParams();
params.width = (int)(converted*WIDTH_RATIO);
params.height = (int)(converted*HEIGHT_RATIO);
snellen.setLayoutParams(params);
System.out.println("########################################################################### SNELLEN CHART WIDTH: : " + snellen.getWidth());
System.out.println("########################################################################### SNELLEN CHART HEIGHT: : " + snellen.getHeight());
}
});
I have checked what both (converted*WIDTH_RATIO)
and (converted*HEIGHT_RATIO)
are and they are somewhere in the 100's. I have put it inside a handler so I can get the correct getLayoutParams()
because I have had trouble with that in the past.
The problem is that when I print out what the width and hights are they are not what I have set them to inside the params.width
and params.height
. What am I doing wrong here?