在inflate方法的源码可以看到 也就是说 , 如果inflate方法中的root参数为null时 , 不会生成layoutparams , 所以margin会失效 , 所以在inflate方法把root参数绑定成你的parent即可 相关文章: 2021-11-09 2022-12-23 2021-11-25 2021-08-08 2021-10-15 2022-02-23 2021-06-18