Creating a dynamic UI based on server response efficiently

126 Views Asked by At

I have an app where the UI elements are decided in the backend. Whenever the app opens it makes a call to server and server returns a json containing the settings and data based on which the UI will be updated. The current approach we are following is to put all the views possible in the xml file and based on the response, show/hide the views. This is not a very optimal solution because there will be some views which will never be shown but still get rendered by the system hence consuming computing power and ram which ultimately give rise to lags and stuttering problem.

I am trying to figure out how to approach this issue. After doing some research I figured out that creating elements dynamically (creating object of widget and adding to the layout) should be the most optimal way as only the views needed will be created and added to the layout and by doing this system will render only the views that the app needs. Also I found out about the library called Litho which is a declarative framework for UI generation. I want to know from the users if the approach I am thinking is correct? Is there any better way of approaching this problem? Is Litho a good library to achieve what I am looking for? Any kind of help is appreciated. Thankyou!

0

There are 0 best solutions below