Android: Creating a parent layout and extending it to maintain an identical look and feel across all activities of the application

后端 未结 1 1828
鱼传尺愫
鱼传尺愫 2021-02-20 08:36

I am writing an app in which I have mutiple screens which I want to adhere to a certain theme. For example: all screens should have the same background, all screens should have

1条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-20 09:18

    There is no layout inheritance but you can create this bar layout in a separate file and use include to include it in the layouts that you want to have the bar.

    Some of the other stuff could also be done with styles. Create a style for different elements and then add the style to the element in the layouts.

    To do inheritance you can create a layout that you can include in other layouts. Then in a BaseActivity you can modify views, add event listeners, etc for the included layout. Just make sure in your onCreate to call setContentView() before you call super.onCreate().

    0 讨论(0)
提交回复
热议问题