Java Code Examples for android.support.annotation.Dimension#SP
The following examples show how to use
android.support.annotation.Dimension#SP .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleRatingBar.java From SimpleRatingBar with Apache License 2.0 | 5 votes |
/** * Convenience method to convert a value in the given dimension to pixels. * @param value * @param dimen * @return */ private float valueToPixels(float value, @Dimension int dimen) { switch (dimen) { case Dimension.DP: return applyDimension(COMPLEX_UNIT_DIP, value, getResources().getDisplayMetrics()); case Dimension.SP: return applyDimension(COMPLEX_UNIT_SP, value, getResources().getDisplayMetrics()); default: return value; } }
Example 2
Source File: SimpleRatingBar.java From SimpleRatingBar with Apache License 2.0 | 5 votes |
/** * Convenience method to convert a value from pixels to the given dimension. * @param value * @param dimen * @return */ private float valueFromPixels(float value, @Dimension int dimen) { switch (dimen) { case Dimension.DP: return value / getResources().getDisplayMetrics().density; case Dimension.SP: return value / getResources().getDisplayMetrics().scaledDensity; default: return value; } }
Example 3
Source File: Spans.java From spanner with Apache License 2.0 | 4 votes |
/** * @see android.text.style.AbsoluteSizeSpan#AbsoluteSizeSpan(int, boolean) */ public static Span sizeSP(@Dimension(unit = Dimension.SP) final int sp) { return new Span(new AbsoluteSizeSpanBuilder(sp, true)); }