I presume most Java programmers write some helper static methods and most probably even have some helper class including just these. So sooner or later you will need to write static methods like this in Kotlin.
public static float getPxFromDp(Context context, float dp) { Resources r = context.getResources(); return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics()); }
But you will find out you there is not anything like a static method in Kotlin. Fortunately, there are ways around this.
Continue reading