I'd like to create custom nested views like below:
It's easier to create a static custom view where all the components are defined in the view.
In this present scenario, I'd like to create custom view that inflates other views, but will also be a ViewGroup that will contain other arbitrary views.
Now, the tricky part is how to inflate subsequent views into the content container view.
custom_panel.xml
<LinearLayout>
<TextView text="Title" />
<CardView>
<LinearLayout id="+@id/contentContainer"></LinearLayout>
</CardView>
</LinearLayout>
CustomPanel.java
public class CustomPanel extends LinearLayout {
// ... Constructor to inflate above layout
}
activity.xml
<app.CustomPanel>
<LinearLayout>
<!-- some other arbitrary views that should be inflated inside content layout -->
</LinearLayout>
</app.CustomPanel>
I already know how to inflate custom views but I'm looking for, maybe a method, that I can override to add specific child views to the content container (another child) so the former views are not directly descendants on the parent view.