[英]Toolbar title not visible with CollapsingToolBarLayout
<android.support.design.widget.AppBarLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!-- ****************** TOOLBAR ******************* -->
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|snap"
>
<android.support.v7.widget.Toolbar
app:layout_scrollFlags="scroll|enterAlways|snap"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/toolbar"
>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
Hello everyone. 大家好。 My toolbar is not visible even though I have set it in my activity with: 即使在活动中使用以下工具设置了我的工具栏,它也不可见:
(toolbar.setTitle("TITLE");
toolbar.setTitleTextColor(0xFFFFFF);
I have provided a snip of my .XML file. 我提供了.XML文件的片段。 Since I am a noob, I'm requesting the stackoverflow army for help. 由于我是菜鸟,因此我向Stackoverflow军队寻求帮助。
Thanks a lot for helping me out. 非常感谢您的帮助。
If you need to set in in your Activity you can use support action bar like this. 如果您需要在“活动”中进行设置,则可以使用类似这样的支持操作栏。
on onCreate
on onCreate
setSupportActionBar(toolbar);
then later when you are going to set your title try this. 然后,当您要设置标题时,请尝试此操作。
if (getSupportActionBar() != null) {
if (title!=null) {
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setTitle(title);
} else {
getSupportActionBar().setDisplayShowTitleEnabled(false);
}
}
If not you may use xml option too: 如果没有,您也可以使用xml选项:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:title="TITLE"
app:popupTheme="@style/AppTheme.PopupOverlay">
Hope it helps. 希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.