mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-12-05 13:48:02 +08:00
fix layout include from merge
This commit is contained in:
parent
9414f26bf0
commit
2556b1a965
@ -113,14 +113,16 @@ static void startElement(void *userData, const XML_Char *name, const XML_Char **
|
|||||||
pd->views.push_back(parent);
|
pd->views.push_back(parent);
|
||||||
pd->flags.push_back(1);
|
pd->flags.push_back(1);
|
||||||
if(pd->root == nullptr|| !pd->attachToRoot)
|
if(pd->root == nullptr|| !pd->attachToRoot)
|
||||||
throw "<merge/> can be used only with a valid ViewGroup root and attachToRoot=true";
|
FATAL("<merge /> can be used only with a valid ViewGroup root(%p) and attachToRoot=true",pd->root);
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strcmp(name,"include")==0){
|
if(strcmp(name,"include")==0){
|
||||||
|
/**the included layout's root node maybe merge,so we must use attachToRoot =true*/
|
||||||
const std::string layout = atts.getString("layout");
|
const std::string layout = atts.getString("layout");
|
||||||
View* includedView = LayoutInflater::from(pd->ctx)->inflate(layout,parent,false,&atts);
|
View* includedView = LayoutInflater::from(pd->ctx)->inflate(layout,parent,true,&atts);
|
||||||
parent->addView(includedView,parent->generateLayoutParams(atts));
|
LayoutParams*lp = parent->generateLayoutParams(atts);
|
||||||
|
includedView->setLayoutParams(lp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user