I struggled with the fact that I think something simple. I set the image to the image button using the class. I want the image to fit the limitations of the screen, but without stretching. That is, if it is too wide to fit the screen, I want the height to be scaled to fit, so that it does not stretch. And if the height is too high, I want the height of the image to decrease, thereby also reducing the width.
I saw this question a couple of times, and I tried all the tips, but for me it doesn't really matter. I think this may have something to do with usnig ImageButton instead of ImageView?
Here are some important pieces of code (badly broken) ...
In my class:
ImageView img = (ImageButton) dialog.findViewById(R.id.fullsizeimage); img.setScaleType(ImageView.ScaleType.CENTER_INSIDE); //Changing ScaleType here has no effect img.setImageBitmap(useThisBitmap);
And here is the contents of the xml layout ...
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageButton android:id="@+id/fullsizeimage" android:background="@null" android:layout_width="wrap_content" android:layout_height="fill_parent" android:adjustViewBounds="true" /> </RelativeLayout>
Some of these junk files in the XML file are probably incorrect. But I changed it so many times, and it has a ZERO effect.
All tips are welcome.
source share