Why option menu items squeezed if I use support library 26? [closed]

こ雲淡風輕ζ 提交于 2019-12-10 05:29:50

问题


The option menu items had the size they supposed to have with support library 25 but when I use 26.0.0, they all get squeezed.

menu item xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/people"
        android:icon="@drawable/icon_addfriends_newsfeed"
        android:title=""
        app:showAsAction="always" />
</menu>

onCreateOptionsMenu in AppCompatActivity

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.newsfeed, menu);
    return true;
}

toolbar layout

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimaryDark"
        android:theme="@style/ToolbarColoredBackArrow"
        app:popupTheme="@style/AppTheme.PopupOverlay"/>

</android.support.design.widget.AppBarLayout>


回答1:


The project didn't have icons for different screen sizes. So, I generated icons with Android Asset Studio for different screen sizes. I chose "Action bar/tab icon generator" in Android Asset Studio when I did. I add those icons into the project. I cleaned up the project and compiled it. It's finally fixed.



来源:https://stackoverflow.com/questions/45429163/why-option-menu-items-squeezed-if-i-use-support-library-26

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!