4

我正在試驗今晚的新聞主題,我想知道是否有人知道這個問題的解決方案。Android的工具欄/支持ActionBar的材質設計

出現在股票Toolbar上,甚至如下所示,當提到自定義佈局文件時。

這是相對較小,但我的強迫症眼睛去正確的,所以也許有人可以幫助。謝謝:)

Screenshot of cropped subtitle descenders.

回答

5

UPDATE:從正確的主題,繼承和對聲明的屬性(有和沒有android:前綴)是修復!

<!-- Base app theme. --> 
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="android:actionBarStyle">@style/MyActionBar</item> 
    <item name="actionBarStyle">@style/MyActionBar</item> 
</style> 

<!-- ActionBar styles. --> 
<style name="MyActionBar" parent="Widget.AppCompat.ActionBar"> 
    <item name="android:titleTextStyle">@style/MyActionBarTitleText</item> 
    <item name="titleTextStyle">@style/MyActionBarTitleText</item> 

    <item name="android:subtitleTextStyle">@style/MyActionBarSubTitleText</item> 
    <item name="subtitleTextStyle">@style/MyActionBarSubTitleText</item> 

    <item name="android:background">@color/blue</item> 
    <item name="background">@color/blue</item> 
</style> 

<style name="MyActionBarTitleText" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"> 
    <item name="android:textColor">@color/white</item> 
</style> 

<style name="MyActionBarSubTitleText" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle"> 
    <item name="android:textColor">@color/white</item> 
    <item name="android:textSize">@dimen/subtitle</item> 
</style> 

+0

真棒的答案! – 2014-11-21 10:15:34

0

如果es0329的回答並不爲你工作,嘗試更換 titleTextStyle通過 titleTextAppearance。它正在爲我工​​作:

<style name="MyActionBar" parent="Widget.AppCompat.ActionBar"> 
     <item name="android:titleTextAppearance">@style/MyActionBarTitleText</item> 
     <item name="titleTextAppearance">@style/MyActionBarTitleText</item> 

     <item name="android:subtitleTextAppearance">@style/MyActionBarSubTitleText</item> 
     <item name="subtitleTextAppearance">@style/MyActionBarSubTitleText</item> 

     <item name="android:background">@color/blue</item> 
     <item name="background">@color/blue</item> 
    </style>