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

Adding support for scale-independent pixels in Resources.getDimension() #1032

Merged
merged 2 commits into from Apr 22, 2014

Conversation

blurpy
Copy link
Contributor

@blurpy blurpy commented Apr 5, 2014

Scale-independent pixels are calculated using metrics.scaledDensity.
scaledDensity is set in Resources.updateConfiguration() like this:

mMetrics.scaledDensity = mMetrics.density * mConfiguration.fontScale;

fontScale was always 0, meaning that scaledDensity also became 0, and resources.getDimension(R.dimen.sp_value) therefore returned 0 no matter the value.

Fixing by running the real Configuration.setToDefaults() from the shadow, which then sets fontScale to 1.

coreydowning added a commit that referenced this pull request Apr 22, 2014
Adding support for scale-independent pixels in Resources.getDimension()
@coreydowning coreydowning merged commit aaf5c02 into robolectric:master Apr 22, 2014
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

Successfully merging this pull request may close these issues.

None yet

2 participants