我一直在嘗試使用支持庫來自定義我的工具欄。雖然設置android:theme在API21 +上完美工作,但較低的API似乎完全忽略它。Android:主題對舊版Apis沒有任何影響
,這裏是我的xml:
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
使工具欄在API21 +白色圖標,圖標保持黑色的舊設備。
更新:我測試了我的appBarLayout添加另一個孩子(tabLayout)。主題正確應用。但即使直接設置,支持工具欄也完全拒絕識別主題。
我已經試過這是我評論對方的回答。無論我如何設置,android:theme值似乎都被完全忽略。 – Ramin