3

When you create a compound view and inflate an xml layout file for it like this:

public class CompundLayout extends LinearLayout{...}

this inflates an xml with root like this:

<LinearLayout ... />

you end up with a layout hierarchy with a LinearLayout inside a LinearLayout (or so I concluded when defining a tag string to the layout object in the xml cased my app to crash).

Am I wrong? is there a better way to do this and prevent this double layout?

1 Answers1

0

There is a better way to avoid the double layout, alter your xml layout to replace the LinearLayout container with a "merge" container. Your xml layout will look something like this afterwards:

<merge xmlns:android="http://schemas.android.com/apk/res/android">
    <TextView ... />
    <EditText ... />
    ...
</merge>
James
  • 88
  • 7