据我所知,我可以设计两种方式toolbar
。
我可以去<TextView>
并在工具栏中写下我想要的任何内容,也许可以去 <Button>
以及下面 <android.support.design.widget.AppBarLayout>
。但谷歌和许多其他人建议的标准方法似乎是使用 <android.support.v7.widget.Toolbar>
它允许您在编写 Activity 代码时膨胀工具栏。
所以我对此有几个疑问
- 这两种方法有什么区别?即,除了当我添加
<TextView>
时我必须为每个 Activity 复制和粘贴这一事实之外,使用其中一个比另一个有什么优势吗?等等。 - 当我使用
<android.support.design.widget.AppBarLayout>
时,我似乎无法找到一种方法来摆脱设置为工具栏标题的 Activity 标题。 。我知道在哪里更改文本,但如何将其完全删除?
最佳答案
- What is the difference of the two methods? i.e is there any advantage of using one over another except the fact that I have to copy and paste for every activity when I just add , etc..
如果您使用工具栏,则可以使用菜单、主页后退按钮等功能,而这些功能是通过 TextView 或按钮无法轻松设置的。
- I just can't seem to be able to find a way to get rid of the title of the activity being set to the title of the toolbar when I use . I know where to change the text but how do I remove it completely?
要删除标题,请使用
getSupportActionBar().setDisplayShowTitleEnabled(false);
或
getSupportActionBar().setTitle(null);
关于java - Android工具栏设计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36377139/