简体   繁体   English

自定义标题栏与 header 的布局

[英]Custom title bar vs. layout with header

I recently thought of adding a custom title bar to my app (with "find me" and home button and such) and then I thought what is the reason of using a custom title bar at top instead of just a normal layout and using it as an include tag at the top of my XML's我最近想在我的应用程序中添加一个自定义标题栏(带有“找到我”和主页按钮等),然后我想是什么原因在顶部使用自定义标题栏而不是普通布局并将其用作我的 XML 顶部的包含标记

What are the pros and cons of each?各自的优缺点是什么? Is there realy a difference?真的有区别吗?

EDIT: one difference ive found so far is that the custom title bar has a shadows automaticly编辑:到目前为止我发现的一个区别是自定义标题栏自动有阴影

For having back and home button titlebar, you should define normal layout for the same.对于具有返回和主页按钮标题栏,您应该定义相同的正常布局。 Because it is easy to implement as compared to customized the native title bar.因为与自定义原生标题栏相比,它易于实现。 And we can create normal layout as we wants with any color/height/width/image backround/etc.我们可以使用任何颜色/高度/宽度/图像背景/等创建我们想要的正常布局。

I suggest you to go with defining normal layout for the title bar instead of customizing the native title bar.我建议您使用 go 定义标题栏的正常布局,而不是自定义本机标题栏。

You can extend LinearLayout to create a new layout with your title bar.您可以扩展 LinearLayout 以使用标题栏创建新布局。 The advantage is you can then customise the title bar for different activities that use it.优点是您可以为使用它的不同活动自定义标题栏。 Some may not want to display the find button for instance.例如,有些人可能不想显示查找按钮。

If you use include in XML you don't have the same flexibility.如果您在 XML 中使用包含,则您没有相同的灵活性。 I would create a custom layout with the title bar.我会用标题栏创建一个自定义布局。

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

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