Android bar has action icon icons compressed if inflated from fragment (layout issue?)

After updating my compileSdkVersion, targetSdkVersion and Google icons in the app bar were compressed in height.

Then before updating the dependencies, all the icons where in the correct aspect (square), but after updating my project dependencies, all the inflated icons in the app bar were squeezed in height. Bellow follows the difference between the update.

I also notice that the squeeze only happens if the inflated button is pumped out of the fragment.

Screenshots:

Search icon is ok before updating

Search icon shrinks in height after update

Android Studio version is AS3 Cannary 8.

Update on Gradle ...

  • Before update (icons with correct aspect)

App / build.gradle:

android {
    compileSdkVersion 25
    ...
    targetSdkVersion 25
    ....
}

ext.supportLibraryVersion = '25.4.0'
ext.playServicesLibraryVersion = '11.0.2'

dependencies {
    // Android Support
    implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
    implementation "com.android.support:design:$supportLibraryVersion"
    implementation "com.android.support:support-v4:$supportLibraryVersion"
    implementation "com.android.support:recyclerview-v7:$supportLibraryVersion"
    implementation "com.android.support:cardview-v7:$supportLibraryVersion"
    implementation 'com.android.support:multidex:1.0.1'
    implementation "com.google.android.gms:play-services-gcm:$playServicesLibraryVersion"
    implementation "com.google.firebase:firebase-appindexing:$playServicesLibraryVersion"
}

      

  • After update (bad aspect icons)

App / build.gradle:

android {
    compileSdkVersion 26
    ...
    targetSdkVersion 26
    ....
}

ext.supportLibraryVersion = '26.0.0'
ext.playServicesLibraryVersion = '11.0.4'

dependencies {
    // Android Support
    implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
    implementation "com.android.support:design:$supportLibraryVersion"
    implementation "com.android.support:support-v4:$supportLibraryVersion"
    implementation "com.android.support:recyclerview-v7:$supportLibraryVersion"
    implementation "com.android.support:cardview-v7:$supportLibraryVersion"
    implementation 'com.android.support:multidex:1.0.2'
    implementation "com.google.android.gms:play-services-gcm:$playServicesLibraryVersion"
    implementation "com.google.firebase:firebase-appindexing:$playServicesLibraryVersion"
}

      

Layout bloated in the app bar:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".activity.MainActivity">
    <item
        android:id="@+id/action_search"
        android:icon="@drawable/search"
        android:orderInCategory="125"
        android:title="@string/search"
        app:showAsAction="always" />
</menu>

      

Layout app bar to be overstated:

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    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/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways">
    </android.support.v7.widget.Toolbar>

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

      

Code to bloat the view above:

public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        super.onCreateOptionsMenu(menu, inflater);

        inflater.inflate(R.menu.search_menu, menu);
}

      

Any ideas on this issue? Is this a bug or am I missing something?

+3


source to share





All Articles