2017-02-14 76 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