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

Strange size values #23

Open
2ndGAB opened this issue Feb 17, 2017 · 5 comments
Open

Strange size values #23

2ndGAB opened this issue Feb 17, 2017 · 5 comments

Comments

@2ndGAB
Copy link

2ndGAB commented Feb 17, 2017

Hello,
I encounter a strange behavior with app:srb_starSize and app:srb_starsSeparation.
I've created a layout with value 42dp for both of these values, displaying 5 stars.
That perfectly render on Nexus7 (1920x1080, 7 inches):
ratingBar

But it only displays 3 stars on a Galaxy S4 (1920x1080, 5.4 inches).
So I wanted to have a look at the star and separation size to see if I have to adapt the values and they are quite surprizing:
On Nexus 7:
ratingBar.getStarSize() = 0.0
ratingBar.getStarsSeparation() = 84.0

On Galaxy S4:
ratingBar.getStarSize() = 0.0
ratingBar.getStarsSeparation() = 126.0

How do you explain these values?

@FlyingPumba
Copy link
Owner

I don't know why it shows only 3 starts on Galaxy S4.

But the values you have are to be expected.
The dp measure unit it's dependent on the ppi (pixel density of the device. Although both devices have the same resolution, they don't have the same ppi.
You can see here that Galaxy S4 has 441 ppi, where here that Nexus 7 has 216 ppi. Thus, 42 dp is 126 pixels on Galaxy S4, but 84 pixels on Nexus 7

@2ndGAB
Copy link
Author

2ndGAB commented Feb 19, 2017

@FlyingPumba so it explain how the display is not correct I think.

Let's start by the nexus 7. Here is the screen part in full width:
Imgur

The screen is 1080 pixels wide. If the value of 84 pixels for 42 dp is correct then, 5 stars and 4 spaces occupies 84 * 9 = 756 pixels, which seems to be quite logical regarding the screenshot.

Now let's consider the Galaxy S4 case:
Imgur

The screen is also 1080 pixels wide.If the value of 126 pixels for 42 dp is correct then, 5 stars and 4 spaces occupies 126* 9 = 1134 pixels, which explains why the 7 stars cannot be displayed.

So I think there is something wrong somewhere.

I think that for 2 devices with the same screen resolution, the size in pixels should be the same no?

Or there is something I didn't undestand.

And why getStarSize() returns 0?

I think it would be very intersting to have a fill option for srb_gravity, which calculates automatically srb_starsSeparation to fill the available space.

@FlyingPumba
Copy link
Owner

@2ndGAB getStarSize() shouldn't return 0, that's weird.
The problem here is that I can't reproduce this behaviour, since I don't have a Galaxy S4 or a Nexus 7.
If you can provide a sample project I'll try to reproduce it on my phone.

I think it would be very intersting to have a fill option for srb_gravity, which calculates automatically srb_starsSeparation to fill the available space.

srb_gravity is not meant for that, it only changes the direction of the fill. Nevertheless, the behaviour you describe is the default behaviour when the user doesn't provide star separation.

Perhaps the problem is related to the fact that you are using the rating bar on a dialog, have you tried a normal layout to see what happens ?

@2ndGAB
Copy link
Author

2ndGAB commented Feb 24, 2017

Nevertheless, the behaviour you describe is the default behaviour when the user doesn't provide star separation.

! ? ! There is a big problem here because it's not the default behavior I see.

here is the sample test project.

@FlyingPumba
Copy link
Owner

@2ndGAB I'll look into the example project. and let you know if I find anything.

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

No branches or pull requests

2 participants