Yesterday I switched to new support library 26 and I also had to change the deprecated AppBarActivity to AppCompatActivity since this is not existing anymore.
I'm experiencing the same problem as described in the link below but "clean" or "rebuild" does not fix the issue. Why option menu items squeezed if I use support library 26?
I'm having all my icons in hdpi and xhdpi. Some also in mdpi and ldpi...
So why do my toolbar icons get squeezed?
Here is the code I use in all my layouts which worked with all previous support libraries (and I'm always using the most recent versions!):
<android.support.design.widget.AppBarLayout
android:id="@+id/myAppBar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/my_awesome_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize" />
</android.support.design.widget.AppBarLayout>
All my icons are defined as attr so that I'm able to provide a light and a dark version.
<item
android:id="@+id/action_logbook"
android:icon="?attr/icon_book"
android:orderInCategory="100"
android:title="@string/logbook"
yourapp:showAsAction="ifRoom"/>
This is the attr in icons.xml
<attr name="icon_book" format="reference"/>
This is the style which provides the actual icon:
<style name="MyBaseThemeLight" parent="Theme.AppCompat.Light.NoActionBar">
<item name="icon_book">@drawable/icon_book_white</item>
</style>
Here is a screenshot from before support version 26.0.0:
UPDATE: It is working when I put an ImageView directly in Toolbar:
<android.support.design.widget.AppBarLayout
android:id="@+id/myAppBar"
style="@style/myAppBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/my_awesome_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="?attr/bt_expenses" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
UDATE 2: For me the code change in version 26 of ActionMenuItemView seems to be the problem since it does not resize the icons to keep width and high equal:
See:
public void setIcon(Drawable icon)
...
See this thread on the Android issue tracker where I explain the bug: https://issuetracker.google.com/issues/64207386. I've also recompiled the library to fix the issue. Attached here: https://issuetracker.google.com/issues/64207386#comment19.
EDIT: The issue is fixed on 26.0.2