【问题标题】:Imageview scaling keeping height fix and width variableImageview缩放保持高度固定和宽度可变
【发布时间】:2013-05-23 07:55:59
【问题描述】:

我想让图像视图的高度恒定,并且基于纵横比宽度应该有所不同。但是我可以看到如果我将宽度作为 wrap_content 则高度小于固定高度,因为保持纵横比,与 wrap_content 宽度相对应的高度小于固定高度。我想调整宽度以保持高度精确为固定值。

【问题讨论】:

标签: android android-layout


【解决方案1】:

您可以将scaleType 更改为 MATRIX。然后你可以自己管理大小,它不会尝试保存纵横比

【讨论】:

    【解决方案2】:

    https://github.com/KyoSherlock/AspectRatioLayout

    也许这就是你想要的。您可以使用 AspectRatioImageView。

    <com.sherlock.aspectratio.AspectRatioImageView android:layout_width="200dp" android:layout_height="wrap_content" android:background="@android:color/holo_blue_bright" android:contentDescription="@null" android:scaleType="centerCrop" android:src="@drawable/ic_launcher" app:widthHeightRatio="2" >

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多