I'm creating an Android activity where there's a ScrollView with a ViewPager and a TextView in it. The ViewPager's pages are Fragments with a single ImageView in them. I load images with Glide into the ImageView.
I want the image's width to fill the screen and the height to be resized to keep the ratio of the image. The problem is that
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent" />
with
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
in it won't work. The image's height is always 0.
I found a suboptimal solution: https://stackoverflow.com/a/19505733/4420321. The problem is that I need to know the exact ratio of the image to resize the height properly.
Right now it's working with 800x600 images, but not with any other. Is there any way to get it working with any ratio? Or is there a better solution for this problem?