mirror of https://github.com/termux/termux-app
Added: Add `ViewUtils.pxToDp()`
This commit is contained in:
parent
14e9a8b6fc
commit
fa829623a8
|
@ -221,6 +221,10 @@ public class ViewUtils {
|
|||
public static float dpToPx(Context context, float dp) {
|
||||
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context.getResources().getDisplayMetrics());
|
||||
}
|
||||
|
||||
/** Convert value in pixels (px) to device independent pixels (dp) units. */
|
||||
public static float pxToDp(Context context, float px) {
|
||||
return px / context.getResources().getDisplayMetrics().density;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue