Android ViewStubA ViewStub is a zero-sized invisible View which is used to load "layout resource" at runtime. ViewStub is a zero dimension View, so you will not see anything on the layout pallete. To make parent resource visible, inflate() method is invoked. To make ViewStub visible or invisible, setVisibility(int) method is invoked. The View.VISIBLE constant is used for making ViewStub visible and View.GONE constant is used for invisible. Example of ViewStubLet's create an example of ViewStub View that displays and hides an ImageView (image) created in another layout (my_layout.xml) file. File: activity.xml File: my_layout.xml File: MainActivity.java Output
Next TopicAndroid TabLayout
|