android 为什么自定义的view不能显示LayoutInflator.inflate方法加载的布局,
PHP中文网
PHP中文网 2017-04-17 17:23:23
0
4
669

我的那个方法写在构造方法里面

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(4)
伊谢尔伦

You should just put the code that loads the layout into the first constructor.

刘奇

Can a custom view load the layout like this?
Customizing the view is to write the custom control into the layout file or code. The construction method with two parameters in the picture is to write the control in XML

Peter_Zhu

1. The construction of a parameter is used in the code. The structure of the two parameters is used in xml

2. Let’s talk about the inflate method.

It goes without saying that you know the first parameter. It’s the layout file,

The second parameter is to set the parent layout of this View. The LayoutParams type of the view obtained by inflate will become the LayoutParams type of the parent layout

When the third parameter is true, the view obtained by inflate will replace the ViewGroup passed in the second parameter, otherwise it will not replace it

左手右手慢动作

Just replace the second parameter null with this

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template