以编程方式将 imageview 的高度设置为 matchparent [英] set height of imageview as matchparent programmatically

查看:26
本文介绍了以编程方式将 imageview 的高度设置为 matchparent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要以编程方式将 imageview 的高度设置为 ma​​tchparent.如果它是固定高度,我知道如何设置.

I need to set the height of an imageview as matchparent programatically.if it is a fixed height i know how to set.

但是我怎样才能将它设置为 matchparent?

but how can i set it as matchparent?

实际上父布局的高度是动态的,所以我需要将imageview的高度作为父布局的高度.

actually height of the parent layout is dynamic.so i need to make the height of the imageview as the height of parent.

推荐答案

启动 LayoutParams .

initiate LayoutParams .

分配父级的宽度和高度并传递给imageview的setLayoutParams方法

assign the parent's width and height and pass it to setLayoutParams method of the imageview

这篇关于以编程方式将 imageview 的高度设置为 matchparent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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