Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the utility of the third argument of View.resolveSizeAndState()?

Tags:

android

I went to the official doc page android google official doc, but it seems that they made a serious typo : we have no information about the third argument of the method. So I just wonder if someone already knows how to define this third int argument.

like image 470
loloof64 Avatar asked Nov 30 '12 18:11

loloof64


1 Answers

The childMeasuredState is the value returned by View.getMeasuredState(). A layout will aggregate its children measured states using View.combineMeasuredStates(). Here is an example:

int childState = 0;

for (int i = 0; i < count; i++) {
    final View child = getChildAt(i);
    if (child.getVisibility() != GONE) {
        measureTheChild(child);
        childState = combineMeasuredStates(childState, child.getMeasuredState());
    }
}

In most case however you can simply pass 0 instead. The child state is currently used only to tell whether a View was measured at a smaller size than it would like to have. This information is in turn used to resize dialogs if needed. In your particular case you shouldn't worry about it.

like image 168
Romain Guy Avatar answered Oct 20 '22 17:10

Romain Guy