【问题标题】:wrap_content larger than actual imageviewwrap_content 比实际的 imageview 大
【发布时间】:2015-02-13 15:40:06
【问题描述】:

我有一个简单的问题,我有一个简单的RelativeLayout 和一个ImageView(很快会添加更多内容)。但是,ImageView 的宽度和高度设置为wrap_content,但是当检查时,宽度正确对齐(可能是因为它是屏幕的最大宽度)但高度似乎比实际图像更进一步。这些图像是通过 Adob​​e Illustrator 制作的,然后导出为 .png,DPI 为 480。

例子:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    tools:context=".MainActivity"
    android:background="#d1070707">


 <ImageView
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:id="@+id/outer_shell"
     android:layout_centerVertical="true"
     android:layout_centerHorizontal="true"
     android:src="@drawable/out_shell" />

</RelativeLayout>

[由于rep

问题:http://postimg.org/image/75ijbo1zv/

显示我的图片没有更大的边框:http://postimg.org/image/mog8ijghb/

但是,如果我将图像进一步向下移动到包裹内容区域理论上会被切断的位置,它会根据我设置的边距值将自身(高度)调整得越来越小。 所以,如果有人知道它为什么会这样并且可以解释,那就太好了!

【问题讨论】:

    标签: android xml android-imageview dpi android-relativelayout


    【解决方案1】:

    这是一个老问题,但有人可能会偶然发现,所以我会留下答案。

    我遇到了同样的问题,设置 android:adjustViewBounds="true" 帮助了我。它使 ImageView 调整自身大小以适应图像。

    【讨论】:

      猜你喜欢
      • 2014-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-30
      • 1970-01-01
      • 1970-01-01
      • 2021-04-22
      相关资源
      最近更新 更多