Android - add one xml layout to another xml format

I have two XML layouts declared in the res / layout folder, which contains a common template, and the other contains views specific to a particular screen. I want to add a second xml layout to the first, i.e. to the general. Since both of these layouts are declared as XML, I cannot add them to another. How to solve this problem?

+4
source share
2 answers

Have you tried using LayoutInflater and inflated your specific view and added it to the ViewGroup or FrameLayout?

+9
source

Perhaps I do not understand him correctly. But the easiest way is to use the <include layout="@layout/yourlayouthere" /> method to simply embed using only XML notation. I use this method to assemble a bunch of small parts and then connect them in the main layout using the inlcude statement.

+16
source

All Articles