【问题标题】:How to show original size of the image without it being stretched in Android?如何显示图像的原始尺寸而不在Android中拉伸?
【发布时间】:2014-12-03 05:19:46
【问题描述】:

对不起我的英语,实际上问题是我通过android中的json获取图像但是当我以全尺寸显示它时,图像被拉伸了你能告诉我该怎么做吗??

这是我的 xml 文件

  <ImageView
    android:id="@+id/portFullImage"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_marginBottom="115dp"
    android:layout_marginLeft="18dp"
    android:layout_marginRight="22dp"
    android:layout_marginTop="70dp"
    android:src="@drawable/logo" />

【问题讨论】:

  • 尝试在代码中添加android:scaleType="center"。
  • 您应该在发布问题之前进行搜索。我猜这是非常基本的事情。阅读documentation
  • 不,它使我的图像太小。这是我的全尺寸图片link
  • 然后试试android:scaleType="fitXY"。
  • android:layout_width="wrap_content" android:layout_height="wrap_content"

标签: android xml imageview fullscreen


【解决方案1】:

也许你可以尝试在 ImageView 中使用 scaleType

<ImageView
 android:scaleType="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/logo" />

【讨论】:

    【解决方案2】:

    如果我认为设备很小,您已经使用android:layout_marginTop="70dp"android:layout_marginBottom="115dp" 指定了topbottom 边距,这将是非常大量空间。它会让你的ImageView 变得很小。

    如果您不介意,请尝试 android:scaleType="centerInside" 看看是否有帮助。您可以尝试以下参考文档中提到的其他比例类型并检查结果。

    参考: Various ScaleType of ImageView , ScaleType

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-03
      • 1970-01-01
      • 1970-01-01
      • 2019-05-02
      • 2012-10-07
      • 1970-01-01
      • 2018-07-02
      • 1970-01-01
      相关资源
      最近更新 更多