From bf34d2ce82494e8f4422d663b4e6945cbfb34db7 Mon Sep 17 00:00:00 2001 From: Oluwadara Abijo Date: Tue, 7 Apr 2026 14:41:34 +0100 Subject: [PATCH] fix(ADFA-2872): Set default layout params values --- .../layouteditor/editor/callers/ViewCaller.java | 12 ++++++++---- .../codeonthego/layouteditor/tools/XMLParserUtils.kt | 1 + .../layouteditor/tools/XmlLayoutParser.kt | 8 +++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/ViewCaller.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/ViewCaller.java index 6f4b366b16..ecb9cfd421 100644 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/ViewCaller.java +++ b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/ViewCaller.java @@ -17,13 +17,17 @@ public static void setId(View target, String value, Context context) { } public static void setLayoutWidth(View target, String value, Context context) { - target.getLayoutParams().width = (int) DimensionUtil.parse(value, context); - target.requestLayout(); + if (target.getLayoutParams() != null) { + target.getLayoutParams().width = (int) DimensionUtil.parse(value, context); + target.requestLayout(); + } } public static void setLayoutHeight(View target, String value, Context context) { - target.getLayoutParams().height = (int) DimensionUtil.parse(value, context); - target.requestLayout(); + if (target.getLayoutParams() != null) { + target.getLayoutParams().height = (int) DimensionUtil.parse(value, context); + target.requestLayout(); + } } public static void setBackground(View target, String value, Context context) { diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/XMLParserUtils.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/XMLParserUtils.kt index cd2fcce13e..04cde33780 100644 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/XMLParserUtils.kt +++ b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/XMLParserUtils.kt @@ -56,6 +56,7 @@ object XmlParserUtils { attributeMap: MutableMap, marker: String ): View = View(context).also { + it.layoutParams = ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT) val attrs = AttributeMap().apply { putValue(marker, "true") } attributeMap[it] = attrs } diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/XmlLayoutParser.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/XmlLayoutParser.kt index f4a19d8839..3482cd09a0 100644 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/XmlLayoutParser.kt +++ b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/XmlLayoutParser.kt @@ -227,7 +227,13 @@ class XmlLayoutParser( throw result } else { view = result as? View - view?.let { listViews.add(it) } + view?.let { + it.layoutParams = ViewGroup.LayoutParams( + ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.WRAP_CONTENT, + ) + listViews.add(it) + } } } }