2017-02-14 87 views
0

这是与文本颜色的工具栏的截图为白色的Android工作室应用更改工具栏文本颜色

我是新来的Android很抱歉,如果这是比较简单的。我希望工具栏包含背景图片,如截图所示。不过,我希望工具栏上的文字更清晰可见,例如黑色(#000)。我试图改变主题,但我失去了将图像作为背景的能力。请任何人都可以帮忙。

下面是我的activity_main.xml中

<android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      app:popupTheme="@style/AppTheme.PopupOverlay" 
      android:background="@drawable/yellow_notebook_head" 
      android:transitionGroup="false" 
      android:backgroundTintMode="screen" 
      android:titleTextColor="#000" 
      /> 
    </android.support.design.widget.AppBarLayout> 

    <include layout="@layout/content_main" /> 

</android.support.design.widget.CoordinatorLayout> 

回答

0

尝试使用:

Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar); 
toolbar.setTitleTextColor(android.graphics.Color.BLACK); 
+0

谢谢你,但你的代码去哪里?在activity_main.xml中?你可以添加上下文的代码? – dcraven

+0

在你的活动'onCreate'调用'setContentView(R.layout.your_layout)'后 – rafsanahmad007

+0

你是一个天才!谢谢 – dcraven

-1

尝试设置背景图片父布局的所有代码。

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/AppTheme.AppBarOverlay" 
      android:background="....."> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     app:popupTheme="@style/AppTheme.PopupOverlay" 
     android:background="@drawable/yellow_notebook_head" 
     android:transitionGroup="false" 
     android:backgroundTintMode="screen" 
     android:titleTextColor="#000" 
     /> 
</android.support.design.widget.AppBarLayout> 

<include layout="@layout/content_main" /> 

+1

谢谢,但我不知道你的意思,或如何,甚至做到这一点? – dcraven

+0

看到编辑后:) – Mirza715

+0

谢谢,它不工作不幸。上面的答案解决了它:) – dcraven

相关问题