I have res/layout/toolbar.xml
which is:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:elevation="4dp"
style="@style/ToolbarStyle">
</android.support.v7.widget.Toolbar>
Here is my usage of toolbar:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar" />
<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
I include it in any Activity
Action buttons are shown and work as expected but there is one thing that action button pressed highlight does not fit toolbar
Has anyone faced this kind of problem?
Thank you
It should be a comment, but I it is too long.
It is a material spec.
As you can see in the picture attached, the toolbar height is 64dp in tablet (56dp in smartphone), while the action button height is 48dp.
Also you can check the layout margin enabling in debug menu "show layout margin".
Source:
Here the specs for a smartphone:
If you check the style Widget.AppCompat.ActionButton
you will find the minHeight and minWidth specs:
values:
<style name="Base.Widget.AppCompat.ActionButton" parent="">
<item name="android:minWidth">@dimen/abc_action_button_min_width_material</item>
<item name="android:minHeight">@dimen/abc_action_button_min_height_material</item>
</style>
<dimen name="abc_action_button_min_height_material">48dp</dimen>
<dimen name="abc_action_button_min_width_material">48dp</dimen>
values-v21:
<style name="Widget.Material.ActionButton" parent="Widget.ActionButton">
<item name="minWidth">@dimen/action_button_min_width_material</item>
<item name="minHeight">@dimen/action_button_min_height_material</item>
</style>
<dimen name="action_button_min_width_material">48dp</dimen>
<dimen name="action_button_min_height_material">48dp</dimen>
I'm not entirely sure this will solve your problem but try replacing
android:layout_height="?actionBarSize"
with
android:layout_height="?android:attr/actionBarSize"
in toolbar.xml. Again, not entirely sure it will work.