INNER CODE UNIT · Java
dpToPx
florent37/ShapeOfView · shapeofview/src/main/java/io/github/florent37/shapeofview/ShapeOfView.java:109
protected float dpToPx(float dp) {
return dp * this.getContext().getResources().getDisplayMetrics().density;
}
protected float pxToDp(float px) {
return px / this.getContext().getResources().getDisplayMetrics().density;
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (changed) {
requiresShapeUpdate();
}
}
private boolean requiresBitmap() {
return isInEditMode() || (clipManager != null && clipManager.requiresBitmap()) || drawable != null;