Use layout editor effectively on layouts with non-static fragments

烈酒焚心 提交于 2019-12-01 02:27:25

问题


With all the Android development tools greatness, especially as of version 21, the graphical layout editor is a powerful tool to have visual control over a layout with fragments for every configuration and locale. I'm aware that a typical Activity's layout XML will contain static fragment tags with info embedded for the layout editor, for example tools:layout="@layout/book_collection_view_window_list".

However, because I need to replace the Fragments in my window dynamically, I cannot use the static fragment tags, and instead need to provide containers, such as FrameLayout, to which I can refer in replace(). Is there something like tools:layout or tools:context I can use on this container so in the layout editor there is more than just black emptyness, and so I can leverage the design and verification features it would give me?


回答1:


It looks, according to the documentation for FrameLayout, like there is an attribute you can use on the FrameLayout tag to put a drawable in the foreground of the ViewGroup.

You could use this to see the FrameLayout whilst you are setting up your view. I often just put a colour in so I can see where it is relative to the background and other Views.



来源:https://stackoverflow.com/questions/13675456/use-layout-editor-effectively-on-layouts-with-non-static-fragments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!