【问题标题】:How can specific the layout_width and layout_height of a Framelayout which fits an image如何指定适合图像的 Framelayout 的 layout_width 和 layout_height
【发布时间】:2010-04-28 06:05:29
【问题描述】:

我有一个 80 像素 X 50 像素的图像,我需要将其放置在 FrameLayout 的一个子项中,如何指定适合图像而不缩放的 Framelayout 的 layout_width 和 layout_height?

我知道 FrameLayout 有一个 layout_height="wrap_content" layout_wight="wrap_content",但我不能使用它,因为 FrameLayout 有其他子级。所以我想硬编码 FrameLayout 的宽度/高度以匹配图像的尺寸?

我应该使用 layout_width="80px" 还是 layout_width="80dip"?

谢谢。

【问题讨论】:

    标签: android


    【解决方案1】:

    您可以使用 layout_width="80px" + layout_height="80px" + scaleType="fitXY" 来指定所需大小的 ImageView。

    dip 取决于屏幕密度,即 1dp != 1px。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-05-19
      • 2021-10-02
      • 1970-01-01
      • 1970-01-01
      • 2013-10-07
      • 2012-01-31
      • 2015-04-07
      相关资源
      最近更新 更多