如何创建一个填充父级高度并显示尽可能大的 Image 的 ImageView? [英] How to create an ImageView that fills the parent height and displays an Image as big as possible?

查看:26
本文介绍了如何创建一个填充父级高度并显示尽可能大的 Image 的 ImageView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按以下方式定义的 ImageView:

I have an ImageView that is defined in the following way:

 <ImageView
  android:id="@+id/cover_view"
  android:layout_width="wrap_content"
  android:layout_height="match_parent"
  android:layout_below="@id/title"
  android:layout_above="@id/divider"
  android:adjustViewBounds="true"
  android:src="@drawable/image_placeholder"
  android:scaleType="fitStart"/>

现在,在下载新的位图后,我更改了可绘制对象.图像现在出现在 ImageView 的左上角.有没有办法让图像填满可能的整个高度,然后调整视图的宽度以在不改变纵横比的情况下缩放图像?

Now after downloading a new bitmap I change the drawable. The image now appears in the top left corner of the ImageView. Is there a way to have the image fill up the whole height that is possible and then adjust the width of the view to enable scaling the image without changing the ascpect ratio?

图像填满了标准屏幕上的所有空间,但在 WVGA 分辨率下,图像仅占 ImageView 实际高度的一半左右.

The image fills up all the space on a standard screen but on a WVGA Resolution the image takes only about half of the actual height of the ImageView.

推荐答案

基本上,这里的答案是你想要达到的目标没有预定义的值.解决方案是创建一个 Matrix适合您的需求并调用 setImageMatrix(matrix) 在你的 ImageView 上.

Basically the answer here is that there is no predefined value for what you are trying to achieve. The solution is to create a Matrix that fits to your needs and call setImageMatrix(matrix) on your ImageView.

这篇关于如何创建一个填充父级高度并显示尽可能大的 Image 的 ImageView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆