2017-06-03 65 views
2

我用一個很簡單的風格來格式化我的工具欄,我使用Android:海拔顯示這樣的工具欄下的陰影:安卓:海拔應用於工具欄和標題

<style 
    name="AppToolbarTheme" 
    parent="AppTheme"> 

    <item name="android:background">@color/colorPrimary</item> 
    <item name="android:titleTextColor">@android:color/white</item> 
    <item name="android:elevation">4dip</item> 
</style> 

而且我申請它只是這樣的:

<Toolbar 
    android:id="@+id/main_toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/AppToolbarTheme"/> 

工具欄下的陰影顯示像我想,howerver它也莫名其妙地應用到工具欄的標題看起來很奇怪:

從風格

回答

2

刪除<item name="android:elevation">4dip</item>並把它放在toolbar XML

<Toolbar 
    android:id="@+id/main_toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/AppToolbarTheme" 
    android:elevation="4dp"/> 
+0

我想這和它的作品,但我不滿意的話,我想聲明我所有的工具欄的屬性的風格。 XML。 –

+0

然後分離佈局文件夾中的工具欄xml,並使用添加它。 –