How to resize / scaletype imageview on Android 8.0 Oreo?

52 Views Asked by At

I have code to scaletype imageview and succesfully tried on Android 4, 5, 6, 7.

But on Oreo, my imageview cant change

I tested on Asus Max Pro M1 Android 8.1

Example of my code below

    iv1 = (ImageView) findViewById(R.id.imageView1);
    iv1.setScaleType(ImageView.ScaleType.FIT_CENTER);

    iv2 = (ImageView) findViewById(R.id.imageView2);
    iv2.setScaleType(ImageView.ScaleType.CENTER_CROP);
1

There are 1 best solutions below

0
On

I want to answer by myself hehe

My solution is change imageView height to equal with device height

If Zenfone max pro m1 display height is 2000 px, so I changed resolution of imageView height to 2000 px too

On my question, my imageView height is 1000 px, so there was nothing happen on Zenfon maxpro m1 when I used CENTER_CROP

Thanks ^_^