I think I can live with all the other views being ...
# android-architecture
u
I think I can live with all the other views being added programatically via kotlin, but how can I make for example the <ImageView> be child of NestedWhatever. Afaik if added as the latter samples, its gonna be on the same level as NestedWhatever, right?
g
I'd probably go with custom view but just as an exercise, you can put all possible variations at once as ViewStubs. Then, you inflate only the one you need. https://android-developers.googleblog.com/2009/03/android-layout-tricks-3-optimize-with.html?m=1
u
Wont I eat view inflating during binding/scroll ? = lag?
Also for custom view, I dont think having it from xml is feasible, is it?
g
ah, forgot that it's in the recycler. In this case no, viewstub will cause only troubles, because during the recycling some rows will be alredy inflated with the wrong view.
and yes, you can put a custom view in some
item_layout.xml
. Most probably with a cost of an extra container. But at least you won't need to set layout params in the code.
u
about the xml, how can you do it? I mean, if you nest it as <MessageView> <TextView/> </MessageView> then afaik textview will be attached to SomeLayout, not NestedWhatever, right? Or did you think make this in code a only include TextMessageView ?
yea, its a mess, imagine you have some complex detail layout and you only change some view in the middle, now you need to either copy paste the whole thing keeping the ids the same, or creating a custom view while attaching the changing part in code to corrent parent
hm guess you could put a container there and expose it via code
😄 thanks rubber duck
r