android 开发的一个小警告
16lz
2021-01-24
在调用--setContentVieW的时候,frameWork构造参数中的每个视图,就会调用相应视图类的构造函数,如果是在XML中声明的layout ,调用setContentVieW(id)一般调用两个参数的构造函数,如果在构造函数中获取此时图的一些信息,包括LayoutParams一般是有问题。
按照 android的框架,在onLayout调用之后在获取,才会有效。而在programingcoding中一般是在onContentView中获取。
mRoot = (LinearLayout)inflate.inflate(R.layout.player, null);
这样产生的mRoot的layoutParam为null
addView(mRoot)
mRoot = (LinearLayout)inflate.inflate(R.layout.player, parent);
这样产生的mRoot的layoutParam 不为null 与XML中声明的一样。
addView(mRoot)
按照 android的框架,在onLayout调用之后在获取,才会有效。而在programingcoding中一般是在onContentView中获取。
mRoot = (LinearLayout)inflate.inflate(R.layout.player, null);
这样产生的mRoot的layoutParam为null
addView(mRoot)
mRoot = (LinearLayout)inflate.inflate(R.layout.player, parent);
这样产生的mRoot的layoutParam 不为null 与XML中声明的一样。
addView(mRoot)
更多相关文章
- C语言函数的递归(上)
- Android研究-linux内核启动到android系统
- android binder 基础实例及解析(一)
- Android下的PVPlayer的实现
- Android之JNI续
- Android中Linux suspend/resume流程
- Android横向滚动屏幕特效分析
- Android(安卓)invalidate与postInvalidate用法
- android 4.4 按键分析三