[英]Styling ActionMode ActionBar in Android 5.0 Lollipop (with AppCompat)
我用這個教程來改造我的Lollipop Holo應用程序: http : //android-developers.blogspot.ru/2014/10/appcompat-v21-material-design-for-pre.html
是)我有的:
主題
<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="windowActionModeOverlay">true</item> <item name="colorPrimary">@color/theme_primary</item> <item name="colorPrimaryDark">@color/theme_primary_dark</item> <item name="colorAccent">@color/theme_accent</item> </style>
工具欄布局
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar" android:layout_height="wrap_content" android:layout_width="match_parent" android:minHeight="?attr/actionBarSize" android:background="?attr/colorPrimary" app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
在多選模式下使用ListFragment片段從ActionBarActivity繼承的活動
getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
結果 :工具欄正常。 它使用sepcified主題顏色,但ActionMode中的ListFragment使用的ActionBar(通過點擊並保持列表項激活)具有標准的Dark.ActionBar顏色。 操作欄的彈出菜單也使用黑暗主題。
我嘗試了所有的SO技巧,但仍然無法解決這個問題。 我將不勝感激任何幫助。
BTW。 我發現ActionBar的深色是由工具欄的app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
,但不知道如何解決這個問題,因為正確的工具欄外觀需要這個屬性。
只需將這兩行添加到主題中:
<item name="actionModeBackground">@color/theme_primary_dark</item>
<item name="actionBarPopupTheme">@style/ThemeOverlay.AppCompat.Light</item>
除了@Andrey Shcherbakov的答案之外,如果您想要更好地控制每種顏色,這也可能會有所幫助。
<!-- action bar title text color, icon color (ie: back icon, icons when editing text)-->
<item name="android:textColorPrimary">#FFFF00</item>
<!-- action bar background color-->
<item name="android:colorBackground">#444400</item>
<!-- color of line under contextual action bar-->
<item name="colorControlActivated">#00CC00</item>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.