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


- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01