Reputation: 3181
I encountered many issues when I changed from ActionBar to Toolbar. i have listed them here
1 ) I have many fragments which are added/replaced using backstack. everything was working fine when i press back button but when I changed to Toolbar, application closes when i press back button.
2 ) Background of popup menu is black.
<item name="android:popupMenuStyle">@style/PopupMenu</item>
<style name="PopupMenu" parent="@android:style/Widget.PopupMenu">
<item name="android:popupBackground">@android:color/white</item>
</style>
even this didnt worked.
If I use AppCompat.Light theme, background color of popupmenu is white, but then NavigationIndicator icons and all that becomes black
3 ) This is my menu style. Here item with id "add" is not shown instead i have used showAsAction as always. it is there in the menu (menu that inflates when i press that 3 vertical dots button), but the icon is not visible.
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".com.hirak.assistere_doit.do_it_main_screen">
<item android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="Settings" />
<item android:id="@+id/add"
android:icon="@drawable/add"
android:showAsAction="always"/>
</menu>
Upvotes: 0
Views: 2057
Reputation: 805
About back button issues.
I had the same problem when i changed to Toolbar.
Problem was in using FragmentManager instead of support.v4.app.FragmentManager
. Creating FragmentManager object by getSupportFragmentManager()
method and changing all fragments import to android.support.v4.app.Fragment
- solved this problem for me.
Upvotes: 0
Reputation: 2999
In order to style the popup menu, you need to apply a popup
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
app:theme="@style/ActionBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:popupTheme="@style/ToolbarPopup" />
and then in your theme, override the values you want changed
<style name="ToolbarPopup" parent="Widget.AppCompat.Light.PopupMenu">
<item name="android:background">@color/white</item>
<item name="android:textSize">14sp</item>
</style>
to change the navigation indicators to white, add to your toolbar
<style name="ActionBar" parent="Widget.AppCompat.Toolbar">
...
<item name="android:textColorSecondary">@color/white</item>
<item name="actionMenuTextColor">@color/white</item>
<item name="android:textColorPrimary">@color/white</item>
</style>
As for the back button issues, I would need more info - code etc.
Upvotes: 6