Android组件ViewStub基本使用方法详解

Android组件ViewStub基本使用方法详解

2023年7月7日发(作者:)

Android组件ViewStub基本使⽤⽅法详解ViewStub可以在运⾏时动态的添加布局。帮助⽂档给定的定义是:"A ViewStub is an invisible, zero-sized View that can be used to lazily inflate layout resources at runtime. When a ViewStubis made visible, or when inflate() is invoked, the layout resource is inflated. The ViewStub then replaces itself in its parentwith the inflated View or Views. Therefore, the ViewStub exists in the view hierarchy until setVisibility(int) or inflate() isinvoked. The inflated View is added to the ViewStub's parent with the ViewStub's layout parameters. Similarly, you candefine/override the inflate View's id by using the ViewStub's inflatedId property.”总之是:ViewStub可以给其他的view事先占据好位置,当需要的时候调⽤inflater()或者是setVisible()⽅法显⽰这些View组件。:

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信