[英]How to setHeight for a ViewGroup
Can you please tell me how can I setHeight for a ViewGroup? 您能告诉我如何为ViewGroup设置高度吗? I see there is a layout(l,t,r,b);
我看到有一个布局(l,t,r,b);
But that is different form setHeight(), since I don't know where should be the top/bottom of the viewGroup. 但这与setHeight()的形式不同,因为我不知道viewGroup的顶部/底部应该在哪里。 I need to set the height of the ViewGroup and return that to ListAdapter.
我需要设置ViewGroup的高度,并将其返回给ListAdapter。
Thank you. 谢谢。
You can try using setLayoutParams()
您可以尝试使用
setLayoutParams()
myViewGroup.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT));
See here the descriptions of the parameters to LayoutParams 在这里查看LayoutParams的参数说明
public ViewGroup.LayoutParams (int width, int height)
Creates a new set of layout parameters with the specified width and height.
width the width, either MATCH_PARENT, WRAP_CONTENT or a fixed size in pixels
height the height, either MATCH_PARENT, WRAP_CONTENT or a fixed size in pixels
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.