Created
July 25, 2015 14:08
-
-
Save TheFinestArtist/bacfb106d43c67ea7a1d to your computer and use it in GitHub Desktop.
DipPixelHelper.java
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
import android.content.Context; | |
import android.content.res.Resources; | |
import android.util.TypedValue; | |
/** | |
* DipPixelHelper | |
* | |
* @author The Finest Artist | |
*/ | |
public class DipPixelHelper { | |
public static float getPixel(Context context, int dip) { | |
Resources r = context.getResources(); | |
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, r.getDisplayMetrics()); | |
} | |
public static float getPixel(Context context, float dip) { | |
Resources r = context.getResources(); | |
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, r.getDisplayMetrics()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment