What was the reason to put view classes to layout instead of inflating layout inside view class?

132 Views Asked by At

Mortar view do not directly inflate it's content. Instead there is an assumption that layout with mortar view will have view content nested in it.

I feel it makes little harder to manage connection between view and it's layout.

What was the reason to put view classes to layout instead of inflating layout inside view class?

1

There are 1 best solutions below

0
On

It's not a requirement, but for one thing it helps with responsive layout. Android can inflate totally different views for you based on configuration. And we like having a single convention in our code, less to think about.

Originally the @Layout annotation could also take a view class reference. We screwed up that code in a way that broke theming, liked this pattern better, and yanked the broken code since we weren't using it anyway. But there's no requirement that you map screens to views that way. That's why the Layout helper is an annotation, not built into any api. And it's why the new PathContainer delegates view construction.