我遵循了很多教程,但我想我错过了一些东西......所以我的问题是我想创建一个像Whatsapp一样的动作模式菜单,Hike使用它。所以我成功创建了它,但它没有正确覆盖在我的工具栏上......
我已经在我的样式表中尝试了以下行,但我不知道,为什么结果没有像我预期的那样反映
<!-- It should be true otherwise action mode will not overlay toolbar -->
<item name="windowActionModeOverlay">true</item>
<!-- For Custom Action Mode Background Color/Drawable -->
<item name="actionModeBackground">@color/colorAccent</item>
工具栏xml:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#1E1E21"
android:id="@+id/toolbar"
android:layout_gravity="center"
android:gravity="center"
app:layout_scrollFlags="scroll|enterAlways"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
local:popupTheme="@style/MyCustomToolBarTheme"
>
<TextView
android:id="@+id/toolbarTitleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="@dimen/ToolbarText"
android:textStyle="bold"
android:textColor="@color/colorAccent"/>
</android.support.v7.widget.Toolbar>
样式表:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<!-- It should be true otherwise action mode will not overlay toolbar -->
<item name="windowActionModeOverlay">true</item>
<!-- For Custom Action Mode Background Color/Drawable -->
<item name="actionModeBackground">@color/colorPrimary</item>
</style>
<style name="RatingBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorControlNormal">#00BFF3</item>
<item name="colorControlActivated">#00BFF3</item>
</style>
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/background_splash</item>
</style>
<style name="MyCustomToolBarTheme" parent="ThemeOverlay.AppCompat.Light">
<item name="android:textColorPrimary">@color/colorAccent</item>
<item name="android:windowActionModeOverlay">true</item>
</style>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="MyMaterialTheme" parent="MyMaterialTheme.Base">
</style>
<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="CircularProgress" parent="Theme.AppCompat.Light">
<item name="colorAccent">@color/buttonbackground</item>
</style>
<style name="MyDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorPrimary">@color/colorPrimary</item>
</style>
实际图片: