造型ActionMode动作条中的Android 5.0棒棒堂(带AppCompat) [英] Styling ActionMode ActionBar in Android 5.0 Lollipop (with AppCompat)
问题描述
我用这个教程换装我的全息应用程序的棒棒糖: <一href="http://android-developers.blogspot.ru/2014/10/appcompat-v21-material-design-for-$p$p.html">http://android-developers.blogspot.ru/2014/10/appcompat-v21-material-design-for-$p$p.html
I used this tutorial to facelift my Holo app for Lollipop: http://android-developers.blogspot.ru/2014/10/appcompat-v21-material-design-for-pre.html
我有什么:
-
主题
Theme
<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>
工具栏布局
Toolbar layout
<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" />
活动继承ActionBarActivity在多选模式ListFragment片段
Activity inherited from ActionBarActivity with a ListFragment fragment in the multi-choice mode
getListView()setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
结果:工具栏就可以了。它使用sepcified主题颜色,但所用的ActionMode的ListFragment的动作条(由活化的自来水和保持一个列表项),拥有标准的Dark.ActionBar颜色。另外,操作栏的弹出菜单中使用黑暗的主题。
Result: The toolbar is OK. It uses the sepcified theme colors, but the ActionBar used by the ListFragment in the ActionMode (activated by tap-and-hold a list item) has the standard Dark.ActionBar colors. Also the popup menu of the action bar uses the dark theme.
我尝试了所有的SO招数,但仍解决不了的。我将AP preciate任何帮助。
I tried all the SO tricks, but still cannot solve that. I will appreciate any help.
BTW。我发现,动作条的暗色调是由工具栏的应用程序引起的:主题=@风格/ ThemeOverlay.AppCompat.Dark.ActionBar
,但不知道怎么解决这一点,因为这个属性是需要正确的工具栏的外观。
BTW. I found that the dark colors of the ActionBar are caused by the toolbar's app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
, but have no idea how solve this, because this attribute is needed for the correct toolbar appearance.
推荐答案
就在这两行添加到主题:
Just add these two lines to the theme:
<item name="actionModeBackground">@color/theme_primary_dark</item>
<item name="actionBarPopupTheme">@style/ThemeOverlay.AppCompat.Light</item>
这篇关于造型ActionMode动作条中的Android 5.0棒棒堂(带AppCompat)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!