如何创建,填补了家长的高度和显示图像尽可能大的ImageView的?图像、高度、家长、ImageView

2023-09-04 12:48:53 作者:伱丟丅ㄋ峩

我有一个是通过以下方式定义的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的左上角。有没有办法让图像填满整个高度有可能再调整视图的宽度,使缩放图像不改变ascpect比例是多少?

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.

推荐答案

基本上这里的答案是,有没有predefined你所要达到什么样的价值。该解决方案是创建一个 矩阵 适合您的需求和呼叫 setImageMatrix(矩阵) 你的的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.