Android: Storybook Layout Heirachy

时间:2016-07-11 22:06:24

标签: android android-layout android-fragments

I am making my first storybook Android app and I'm having difficulty finding the right way to implement how the app decides what layout to have.

Currently I have the following "elements":

Class: BookActivity
Class: PageFragment

Layout: activity_book.xml
Layout: fragment_page1.xml
Layout: fragment_page2.xml

I have BookActivity keep track of what page the app is supposed to be on and pass that info to PageFragment when it creates a new one to "change the page", but I'm having issues referencing the current layout file progmatically and I haven't found someone else doing quite the same thing which leaves me to believe this might be the wrong way to go about it...

The layout of a storybook isn't so dynamic that it warrants doing most layouts programatically (similar to what a game might look like), but it's not so static that layouts can be reused with ease.

Would a "best" way to implement the different page layouts be programatically within each fragment and keep just a single core "page" layout to be reused in all fragments? If the book is 10 pages it seems it would bloat PageFragment quite a bit....

Thanks in advanced for any help I can get.

0 个答案:

没有答案