Android图像缩放问题

标签 android xml image scaling

我是 Android 的新手,刚从 IOS 转过来,遇到了一个小问题。 我有一张很长的图片,因此在平板电脑上图片会横跨整个屏幕而无需缩放图片。

但是当我在手机上打开应用程序时,图像的高度被压缩以适合屏幕。 我该如何阻止它?

Problem

图像在 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/

相关文章:

android - ListView 禁用标题 View 的垂直滚动

android - 移动版仅在左侧显示文字

Python ElementTree 对 HTML 实体进行转义

Android - 找不到 SwipeRefreshLayout 导入

java - 唤醒锁和暂停的应用程序

c# - 从 XML CDATA 获取 img src

xml - 如何使用 XML::Twig 从 URL 中提取一些 XML 数据?

javascript - context.drawImage() 不适用于新的 Image() 实例(chrome)

css - 如何在保持纵横比的同时在 Paperclip 中设置最大宽度或高度

css - 如何在源重定向时显示 CSS 背景图像?