我希望即使在横屏模式下,我的ImageView的长宽比仍然保持不变。即使我使用了scaleType:fitXY和adjustBounds,它看起来也非常拉伸。这是我的xml文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="24dp"
android:layout_gravity="center">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:id="@+id/image" />
/>
</FrameLayout>
</LinearLayout>
更新: 我使用Glide设置了我的ImageView。它主要是一张640 x 330的图片。
Glide.with(this)
.load("http://www.web-cars.com/lambo_sb/IMG_3410.jpg")
.into(imageView);
FitXY
is supposed to stretch the image to fill the screen.Try overridingonConfigurationChanged
- Sunil Sunny