问题描述
我想要动态地调整我的视行的高度(屏幕高度 - 我的布局高度)/则为list.size
I'm trying to dynamically adjust the height of my rows depending on the (screen height - my layout height) / list.size.
不幸的是,在的onCreate
方法的布局高度返回null(没有,所以当我把它在上点击监听器)。
Unfortunately in the onCreate
method the layout height returns null (not so when i call it in an on click listener).
有另一种方法,我可以打电话了吗?
Is there another method I can call it in?
推荐答案
您必须要等到布局发生了,这是继的onCreate()
。您可以通过听 onSizeChanged()
上查看或张贴一个Runnable从这样做的onCreate()(myView.post(新的Runnable() {...}))
。
You have to wait until layout happens, which is after onCreate()
. You can do so by listening to onSizeChanged()
on a View or by posting a Runnable from onCreate() (myView.post(new Runnable() { ... }))
.
这篇关于的LinearLayout高度的onCreate为0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!