I have a screen where the user can read an article (with large photo at the top.
It's general structure is:
LinearLayout -> ScrollView -> LinearLayout -> ImageViews,TextViews...etc
The ImageView I'm having problems with is the large image at the top (below the Article's title, but above it's text:
<ImageView
android:id="@+id/article_photo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/super_light_gray"
android:scaleType="centerCrop"
android:contentDescription="@string/articlePhoto"
android:cropToPadding="true"
android:layout_marginBottom="10dp"
android:padding="1dp"/>
The problem is, the photos appear, but are cropped vertically A LOT so that even vertical-oriented photos show up very skinny and wide. I assumed that "wrap_content" should make it the full height of the photo... but I'm obviously wrong :)
How can I make the photo show up full width (already working), but also full height?
I'm using the UniversalImageLoader to load the images:
if(lrgPhoto != null && !lrgPhoto.filepath.equals(""))
{
imageLoader.displayImage(
"http://img.mysite.com/processes/resize_android.php?image=" + lrgPhoto.filepath + "&size=640&quality=90",
imageView,
imgDisplayOptions
);
imageView.setVisibility(View.VISIBLE); //show photo
}
else
{
imageView.setVisibility(View.GONE); //hide photo
imageView.invalidate();
}
Edit:
If I change 'scaleType' to 'fitXY', then the image shows correct dimensions without being cropped, but then it's not full-width. Is there a way I can have both full-width AND not-cropped strangely?
It appears the "crop" is because it's using the original height of the image for the height, but it's enlarging the image to fit full-width...
Add this to the imageview xml:
android:adjustViewBounds="true"
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