opacapp / multiline-collapsingtoolbar

A modified CollapsingToolbarLayout that can deal with multiline titles
Other
782 stars 113 forks source link

Multiple items in the options menu shorten the text width #26

Closed PattaFeuFeu closed 6 years ago

PattaFeuFeu commented 7 years ago

Once there is a certain amount of items in the options menu, the toolbar text width decreases. On a 1080p xxhdpi phone, more than two items lead to a massive shortage, depending on the text of course.

Attached, you will find screenshots taken with the demo app running and the following changes introduced.

To reproduce, paste the following into menu_demo.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/action_settings0"
        android:icon="@android:drawable/btn_star"
        android:title="@string/settings"
        app:showAsAction="ifRoom" />
    <item
        android:id="@+id/action_settings1"
        android:icon="@android:drawable/btn_star"
        android:title="@string/settings"
        app:showAsAction="ifRoom" />
    <item
        android:id="@+id/action_settings2"
        android:icon="@android:drawable/btn_star"
        android:title="@string/settings"
        app:showAsAction="ifRoom" />

</menu>

Zero items:

zero_items

One item:

one_item

Two items:

two_items

Three items:

three_items

Four items:

four_items

johan12345 commented 7 years ago

Thanks for reporting the issue!

I think it is caused by a change introduced with the Support Library 24.1.1 to 24.2.1 update. I think before it would just move the additional options menu items to the overflow menu if the text was too long.

The problem is that if we want to fix this properly we need to make sure that the title has the correct width in the collapsed state (staying to the left of the icons) and a different width in the expanded state, allowing for additional words in the first line.

This should theoretically be doable, but I am currently quite busy and therefore probably not able look into it very soon. Pull requests are welcome :)

TonyHaddad91 commented 7 years ago

@PattaFeuFeu have u fixed ur issue? Im facing this issue even when i have only one option menu

micookie commented 7 years ago

I have the same problem.

I think expanded Title width used collapsed title's width.... it should re-measure while expanded .

boformer commented 7 years ago

This is still an issue.

SimonSchubert commented 6 years ago

46 I uploaded a pull requested with a fix. It works like a charm for me and hopefully for you guys too.

device-2017-10-23-153359 device-2017-10-23-153409 device-2017-10-23-153424

johan12345 commented 6 years ago

This should be fixed through PR #46 in the next release. @raphaelm, could you make one when you are back from your journey?

johan12345 commented 6 years ago

Ah, and don't forget to take into account #52 when making the new release!

johan12345 commented 6 years ago

The fix from #46 is included in the newest release 27.1.0. Thanks @SimonSchubert !