Questions tagged [viewstub]

A ViewStub is an invisible, zero-sized View that can be used to lazily inflate layout resources at runtime. When a ViewStub is made visible, or when inflate() is invoked, the layout resource is inflated. The ViewStub then replaces itself in its parent with the inflated View or Views. Therefore, the ViewStub exists in the view hierarchy until setVisibility(int) or inflate() is invoked. The inflated View is added to the ViewStub's parent with the ViewStub's layout parameters. Similarly, you can define/override the inflate View's id by using the ViewStub's inflatedId property

Basic Questions..

How to use ViewStub? How to find access to button in viewStub?

109 questions
75
votes
3 answers

How to use View Stub in android

I want to use ViewStub in android, so please help me. I have created ViewStub stub = new ViewStub; View inflated = stub.inflate(); How to use it programmatically?
posteritysystem
  • 973
  • 2
  • 7
  • 20
28
votes
2 answers

How to "deflate" a ViewStub?

So I can inflate a ViewStub at runtime. Let's say I want to make it disappear and then maybe inflate again depending on some event occurring (for example, a toolbar that inflates and deflates according to what the user selects on screen). I can use…
Sid
  • 9,508
  • 5
  • 39
  • 60
26
votes
4 answers

Difference between and in android

What are the differences between <\include> tag and <\ViewStub> tag and which one is preferrable while designing the layout.
Venugopal
  • 1,288
  • 3
  • 19
  • 31
24
votes
3 answers

How to use ViewStub in ConstraintLayout?

It seems that when inflating a ViewStub in a ConstraintLayout, the resulting view has lost all its constraints. I guess we can define the constraints for the inflated view using ConstraintSet, but that kind of defeats the purpose of ViewStub. Is…
joharei
  • 578
  • 1
  • 5
  • 22
22
votes
8 answers

Android Data Binding - how to use ViewStub with data binding

Is there anyway to use viewStubs with dataBinding ? can ViewStubProxy help ? My stub current looks like this:
j2emanue
  • 60,549
  • 65
  • 286
  • 456
20
votes
1 answer
19
votes
8 answers

How to check if a viewStub is already inflated?

I did not find any boolean method does this task. Can I do this by checking if the id of the viewStubchanged to the one specified as inflatedid? Javacode: protected void plantViewTree() { // TODO Auto-generated method stub ViewStub…
Amrmsmb
  • 1
  • 27
  • 104
  • 226
18
votes
7 answers

Android - Is a ViewStub worth it?

I have a ListView where each row of the listview contains about 10 ImageButtons. Most of these buttons have visibility = Gone and only show up in very rare scenarios. I am wondering if it's worth it to replace these ImageButtons with ViewStubs to…
sakis kaliakoudas
  • 2,039
  • 4
  • 31
  • 51
17
votes
1 answer

ViewStub vs. View.GONE

As far as I undestand, neither a ViewStub nor a View that's GONE participate in the measure and layout passes (or rendering anyway). Is there a difference in rendering performance? What's the best practice about when to use which?
mxk
  • 43,056
  • 28
  • 105
  • 132
12
votes
4 answers

RelativeLayout and ViewStub inflation

I have the following layout.
AHTOH
  • 446
  • 4
  • 16
11
votes
0 answers

How to use Kotlin Android Extensions with ViewStub properly?

Does the extensions have a magic to call inflated view? As far as I see, I should break the harmony of code and call findViewById. The intent was to inflate layout_ongoingView layout at sometime, and make hidden, and visible again based on…
blackkara
  • 4,900
  • 4
  • 28
  • 58
9
votes
1 answer

Not able to access ViewStub'child

I am trying to use VIEWSTUB inside the merge tag.and its working well.I'm able to catch onclicklistenr of ViewStub's parent button.But i want to access the button that is inside the viewstub. 1.Main…
Tofeeq Ahmad
  • 11,935
  • 4
  • 61
  • 87
8
votes
1 answer

ViewStub raises error while inflating more than one layouts conditionally

In my app, I am having a spinner, and a ViewStub, depending upon the user item selection from spinner, I have to inflate different layouts and show the inflated layout below the spinner. When my app starts, ViewStub successfully inflates a layout on…
Chandra Sekhar
  • 18,914
  • 16
  • 84
  • 125
7
votes
2 answers

Android ViewStub change layouts programmatically

This is my use case: I want to change my inflated layout at run time, say first I inflate layout a, then after some time I want to show layout B, then layout C etc. I read somewhere that rather than including layouts in main layout and then…
usr30911
  • 2,731
  • 7
  • 26
  • 56
7
votes
2 answers

ProgressBar not animating while inflating viewstub

I have an Activity with this structure: FrameLayout ProgressBar ViewStub The ViewStub inflates a Fragment in a separate thread. What I need is to display the progress while the fragment loads. The problem is the ProgressBar is not spinning…
MariusBudin
  • 1,277
  • 1
  • 10
  • 21
1
2 3 4 5 6 7 8