java - Android工具栏设计

标签 java android toolbar

据我所知,我可以设计两种方式toolbar 。 我可以去<TextView>并在工具栏中写下我想要的任何内容,也许可以去 <Button>以及下面 <android.support.design.widget.AppBarLayout> 。但谷歌和许多其他人建议的标准方法似乎是使用 <android.support.v7.widget.Toolbar>它允许您在编写 Activity 代码时膨胀工具栏。 所以我对此有几个疑问

  1. 这两种方法有什么区别?即,除了当我添加 <TextView> 时我必须为每个 Activity 复制和粘贴这一事实之外,使用其中一个比另一个有什么优势吗?等等。
  2. 当我使用 <android.support.design.widget.AppBarLayout> 时,我似乎无法找到一种方法来摆脱设置为工具栏标题的 Activity 标题。 。我知道在哪里更改文本,但如何将其完全删除?

最佳答案

  1. 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 或按钮无法轻松设置的。

  1. 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/

相关文章:

java - 如何启动嵌入到我的 java 应用程序中的 elasticsearch 5.1?

java - Android 工具栏菜单未在所有 Activity 中显示

android - HomeAsUp 按钮在 Android 4.2.2 和 Appcompat 21.0.0 中无效

android:contentInsetLeft ="0dp"与 app:contentInsetLeft ="0dp"

java - 开始记录 Tomcat 的最简单快捷的方法是什么?

java - 在 ndk 中找不到原生的实现

java - 使用 ANTLR 的嵌套 boolean 表达式解析器

android - 在android中的服务中访问viewModel

Android模拟器多点触控

Android 每 30 秒从 url 加载图像