1

I have a constraintlayout with too many views (atleast 50+) in it. Now it is getting difficult to manage the xml code as it exceeds 1000 lines. I am trying to use tags to divide the code in multiple layouts as mentioned in this post but in tag it does not hold the constraints as views are dependent on other views or parent. So other approach is to use nested constraint layouts as mentioned in this post. So i have two questions:

1- How to use tag with constraintlayout and keep constraints intact?

2- Or use nested constraint layouts? But it think it kills the purpose of having flat view hierarchy

enter image description here

Nouman Bhatti
  • 1,635
  • 3
  • 24
  • 50
  • Why do you need your layout to be so big? I am willing to bet you can break it up into different views or something. With a layout that big you run the risk of having it not being able to inflate on devices because of memory issues – tyczj Apr 09 '18 at 12:51
  • try to use or – srinu Apr 09 '18 at 12:53
  • @tyczj these are multiple menus that are going to animate from offscreen, all of them would not show at a time. They are hidden/offscreen initially. Also there can be other use cases like reusing a layout – Nouman Bhatti Apr 09 '18 at 12:56
  • @srinu i try to use or but if i put lets say a group of 6 buttons in merge there would not be any constraints associated with them how can i set constraints wrt to parent/root layout? – Nouman Bhatti Apr 09 '18 at 12:57
  • suggestion(i am not sure) you can set constraint directly to include/merge layout right. – srinu Apr 09 '18 at 13:02

0 Answers0