我是 Android 的新手,刚从 IOS 转过来,遇到了一个小问题。 我有一张很长的图片,因此在平板电脑上图片会横跨整个屏幕而无需缩放图片。
但是当我在手机上打开应用程序时,图像的高度被压缩以适合屏幕。 我该如何阻止它?
图像在 LinearLayout 上设置为背景:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/blur"/>
我试过:
android:scaleType="fitStart"
android:scaleType="center"
android:scaleType="fitcenter
”
最佳答案
Android 始终缩放背景以适合其 View ,scaleType 仅适用于 ImageViews。您需要使用 android:src
引用图像来实现 ImageView。只有这样你才能开始玩 android:scaleType
。
关于Android图像缩放问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20946356/