ImageView的 - 有高度匹配的宽度? [英] ImageView - have height match width?

查看:115
本文介绍了ImageView的 - 有高度匹配的宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ImageView的。我想它的宽度被FILL_PARENT。我想它的高度是任何宽度最终被。例如:

I have an imageview. I want its width to be fill_parent. I want its height to be whatever the width ends up being. For example:

<ImageView
  android:layout_width="fill_parent"
  android:layout_height="whatever the width ends up being" />

是类似的东西可能在布局文件,而无需创建自己的视图类?

Is something like that possible in a layout file without having to create my own view class?

感谢

推荐答案

这也许会回答你的问题:

Maybe this will answer your question:

<ImageView
    android:id="@+id/cover_image"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:scaleType="fitCenter"
    android:adjustViewBounds="true" />

您可以忽略 scaleType 属性这一特殊情况。

You can ignore the scaleType attribute for this particular situation.

这篇关于ImageView的 - 有高度匹配的宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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