Last active
July 4, 2019 06:28
-
-
Save quiro91/0e21ed8bbac6c1c525ae543b3111a5d1 to your computer and use it in GitHub Desktop.
Measure minimum width
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private int measureDimension(int desiredSize, int measureSpec) { | |
int result; | |
int specMode = MeasureSpec.getMode(measureSpec); | |
int specSize = MeasureSpec.getSize(measureSpec); | |
if (specMode == MeasureSpec.EXACTLY) { | |
result = specSize; | |
} else { | |
result = desiredSize; | |
if (specMode == MeasureSpec.AT_MOST) { | |
result = Math.min(result, specSize); | |
} | |
} | |
if (result < desiredSize){ | |
Log.e("ChartView", "The view is too small, the content might get cut"); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment