android - 应用程序标题下有关某些 Activity 的文字

标签 android android-fragments fragment android-toolbar layout-inflater

你好,我想在我的应用程序的一些 Activity 中将相同的文本放置在应用程序的标题下(在布局的顶部),而不影响其他对象布局。

但我希望此文本仅在某些内容为 true 时出现,而不是在所有 activities 上出现。 关于我该怎么做的任何建议?我该如何实现?

附言我是安卓新手。

最佳答案

您可以在 toolbar 对象上使用 setSubtitle() 方法。对于自定义,您可以使用 setSubtitleTextAppearance (Context context, int resId)

但是文档说-

A title and subtitle. The title should be a signpost for the Toolbar's current position in the navigation hierarchy and the content contained there. The subtitle, if present should indicate any extended information about the current content. If an app uses a logo image it should strongly consider omitting a title and subtitle.

文档链接 - http://developer.android.com/reference/android/support/v7/widget/Toolbar.html#setSubtitle(java.lang.CharSequence)

关于android - 应用程序标题下有关某些 Activity 的文字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36268564/

相关文章:

android - Firebase 云消息传递重复通知

再次在 onCreateView 中创建的 android fragment 重用布局

安卓 : Parent fragment of a nested fragment

android - 在 Android 上使用 FragmentActivity.getIntent().getExtras() 时出现 NullPointerException

Android ViewPager 查找Fragment for findviewbyid

android - 在 android 中是否可以在更改 Activity 之前留下一个 AlertDialog?

android - 在 webview 中添加进度对话框

android - 使用手机摄像头,在捕获图像 Activity 后不会返回到特定 Activity

android - 在 fragment 中使用 enableAutoManage()

android - 保留 fragment