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

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

问题描述

我需要以编程方式将图像视图的高度设置为 matchparent .如果它是固定高度,我知道如何设置.

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天全站免登陆