简体   繁体   English

修复了Android应用中的页眉和页脚

[英]Fixed header and footer in android app

I want to use fixed header and footer in my android app, but every time a new activity starts, the page refreshes and both the header and footer reload. 我想在我的Android应用中使用固定的页眉和页脚,但是每次启动新活动时,页面都会刷新,并且页眉和页脚都会重新加载。
How can I make them fixed through out the application life cycle so that they never reload, although I can hide, remove and add items to them? 我如何在整个应用程序生命周期内对其进行修复,以便尽管我可以对其进行隐藏,删除和添加,但它们永远不会重新加载?

I've used the include tag and it's not what I want 我用了include标签,这不是我想要的

You may use one Activity with header, footer and the content Fragment. 您可以将一个Activity与页眉,页脚和内容片段一起使用。 Instead of starting new Activity, you'll change the content Fragment. 而不是开始新的Activity,您将更改内容Fragment。

But. 但。 This is not expected neither by Android nor by user. Android和用户都不希望这样做。 Also you need some kind of Back button handling, state saving/restoring and so on. 另外,您还需要某种后退按钮处理,状态保存/恢复等功能。 Are you sure that you want to do what you described? 您确定要按照自己的描述去做吗?

If so, here are some useful links: 如果是这样,这里有一些有用的链接:

Also if you want to use fragments on Android prior 3.0 (API level 11), you'll need the Support Library For custom transit animation 另外,如果您想在Android 3.0之前的版本(API级别11)上使用片段,则需要支持库以自定义运输动画

这是给您的示例示例,如何在整个应用程序中具有固定的页眉和页脚

你可以考虑这个例子

You can use Include tag which can include layout which you want . 您可以使用Include标签,其中可以包含所需的布局。 in every layout of your app just add Include tag as header and footer of your layout 在您应用的每个布局中,只需将Include标签添加为布局的页眉和页脚

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM