set height of imageview as matchparent programmatically(以编程方式将 imageview 的高度设置为 matchparent)
问题描述
我需要以编程方式将 imageview 的高度设置为 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:以编程方式将 imageview 的高度设置为 matchparent
基础教程推荐
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
