2016-11-04 68 views
0

活動:造型工具欄

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    tools:context="com.example.andre.myapplication.MainActivity"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/colorPrimary" 
     android:minHeight="?attr/actionBarSize" 
     style="@style/ToolbarTheme"> 



    </android.support.v7.widget.Toolbar> 

</LinearLayout> 

styles.xml:

<resources> 

    <!-- Base application theme. --> 
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
     <!-- Customize your theme here. --> 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
     <item name="colorAccent">@color/colorAccent</item> 
    </style> 

    <style name="ToolbarTheme" parent="ThemeOverlay.AppCompat.Light"> 
     <item name="android:textColorPrimary">@android:color/white</item> 
     <item name="android:textColorSecondary">@android:color/white</item> 
     <item name="android:textColor">@android:color/white</item> 
    </style> 

</resources> 

但我仍然對工具欄標題巴爾克。爲什麼?

+0

你應該改變你的自定義ToolbarTheme的父母這對我的作品。看看[這個答案](http://stackoverflow.com/a/39344517/5392118)。 –

+0

嘗試'app:titleTextColor =「@ android:color/white」'和更多樣式信息@ http://www.materialdoc.com/toolbars/ – Raghunandan

回答

0

嗨嘗試設置textColor直接到工具欄。如果一切正常,沒有在主題

+1

'toolbar.setTitleTextColor(0xFFFFFFFF);'工作正常。 – demas

+0

是的,這將工作太..但它只會改變標題顏色:) –

0
<style name="ToolbarTheme" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/> 

事情有些奇怪,當我想在工具欄白色標題