Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BootstrapDropdown] Calculation of longest item is wrong #191

Open
StNekroman opened this issue Jan 8, 2017 · 2 comments
Open

[BootstrapDropdown] Calculation of longest item is wrong #191

StNekroman opened this issue Jan 8, 2017 · 2 comments
Labels

Comments

@StNekroman
Copy link

Currently you calculate it as:
measuretext(getLongestItemText()) + paddingLeft + paddingRight.
But that it not corrent, because with of "WWW" will be longer then "iii", while length of both string is the same.
In other words:
image

And final result of bug is here:
device-2017-01-03-212645

In this case, my longest string was "EUR".
But, as you see, even "EUR" doesn't fit in the line.

@StNekroman StNekroman changed the title [BootstrapDropdown] Calcularion of longest item is wrong [BootstrapDropdown] Calculation of longest item is wrong Jan 8, 2017
@StNekroman
Copy link
Author

Additionaly,

return (float) (DimenUtils.dpToPixels(mPaint.measureText(text)));

is not correct, because measureText output is already in pixels.

Although,

mPaint.setTextSize(baselineDropDownViewFontSize * bootstrapSize);

looks like isn't correct as well due to
http://stackoverflow.com/questions/6232541/android-measuretext-return-pixels-based-on-scaled-pixels

@StNekroman
Copy link
Author

StNekroman commented Jan 8, 2017

For debugging needs I set up

<dimen name="bootstrap_dropdown_default_item_left_padding">0dp</dimen>
<dimen name="bootstrap_dropdown_default_item_right_padding">0dp</dimen>

in order to see clean width, without padding adn I got:
image

So, looks like, calculationo of item width is wrong from the begining even for "EUR", which was chosen as longest one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants