【问题标题】:scale Imageview to full screen without straching bitmap.在不拉伸位图的情况下将 Imageview 缩放到全屏。
【发布时间】:2014-10-13 16:04:50
【问题描述】:

当位图为 240*240 大小时,如何将ImageView 缩放到设备全屏。 我使用了以下代码。

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/layoutBGColor"
     android:clickable="true" >

<ImageView
    android:id="@+id/fullImage"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="fitXY" />

 ------
ImageView  iv = (ImageView)findViewById(R.id.fullImage);
iv..setImageBitmap(bitmap);

位图是 240*240,位图看起来是分层的。我用谷歌搜索了thisthis,但没有一个起作用。请建议我如何在不分层的情况下全屏设置位图。

【问题讨论】:

  • 你想要发生什么?图片小于您的屏幕尺寸,因此要么被拉伸,要么周围有空白区域。
  • 不可能,如果位图尺寸小于屏幕,显然需要拉伸以填充它
  • @AleksG 你说的是正确的。请参阅如果我在它(位图)上添加缩放效果,那么它看起来不会被拉伸。我想要这样的东西。我的意思是一些如何显示它的缩放。
  • 如何添加缩放效果?您需要了解,没有办法让小图像在拉伸到大屏幕时看起来不错。如果要显示全屏图像,则必须获得高分辨率图像。

标签: android bitmap imageview


【解决方案1】:

显然,由于图像尺寸小于屏幕尺寸,那么它肯定会拉伸。如果您说的是在拉伸图像时保持纵横比,请尝试以下代码。

<ImageView
    android:id="@+id/fullImage"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:adjustViewBounds="true"
    android:scaleType="fitCenter" />

诀窍是使用android:adjustViewBounds

【讨论】:

    猜你喜欢
    • 2023-03-12
    • 2011-03-14
    • 2020-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多