mirror of
https://github.com/nix-community/nix-on-droid-app.git
synced 2025-11-08 19:46:10 +01:00
Added: Add ViewUtils.pxToDp()
This commit is contained in:
parent
14e9a8b6fc
commit
fa829623a8
1 changed files with 4 additions and 0 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue