From 2556b1a96580c33d0272523927e38f5441b5d306 Mon Sep 17 00:00:00 2001 From: houzh Date: Wed, 26 Jul 2023 18:51:46 +0800 Subject: [PATCH] fix layout include from merge --- src/gui/view/layoutinflater.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/view/layoutinflater.cc b/src/gui/view/layoutinflater.cc index 6e2e5127..b7eb2a0b 100755 --- a/src/gui/view/layoutinflater.cc +++ b/src/gui/view/layoutinflater.cc @@ -113,14 +113,16 @@ static void startElement(void *userData, const XML_Char *name, const XML_Char ** pd->views.push_back(parent); pd->flags.push_back(1); if(pd->root == nullptr|| !pd->attachToRoot) - throw " can be used only with a valid ViewGroup root and attachToRoot=true"; + FATAL(" can be used only with a valid ViewGroup root(%p) and attachToRoot=true",pd->root); return ; } 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"); - View* includedView = LayoutInflater::from(pd->ctx)->inflate(layout,parent,false,&atts); - parent->addView(includedView,parent->generateLayoutParams(atts)); + View* includedView = LayoutInflater::from(pd->ctx)->inflate(layout,parent,true,&atts); + LayoutParams*lp = parent->generateLayoutParams(atts); + includedView->setLayoutParams(lp); return; }