To Convert dp to px or px to dp fisrt we need to calculate device Density DPI Lets create DisplayMetrics object DisplayMetrics displayMetrics= getResources().getDisplayMetrics(); Now calculate devie Density DPI float densityDpi=displayMetrics.densityDpi; Convert dp to px dp*(densityDpi/defaultDPI); Convert px to dp px*(densityDpi/defaultDPI);
we will get density DPI fromDisplaymetrics object.
float defaultDPI=DisplayMetrics.DENSITY_DEFAULT;
Duplicate files during packaging of APK” build.gradle issue: Android Studio
What is ANR? How to avoid and resolve it?
How to avoid multiple button click at same time in android?
How to Exit android app on back pressed?
Permission denied for window type 2010 in Marshmallow device
How do I check in SQLite whether a table exists?
How to get an image resource by it's name in android?
What is Application?
ERR_ACCESS_DENIED in Android Webview with sdk 30
What is "shared preferences" in Android ?
How to validate email address in Android with Kotlin?
How to find Android Device UDID or unique ID?
Check List for Generate Signed APK Android
How to reduce APK package size?
What is Android Fragments?
How to get screen size (width,height) in Android?
Invoke-customs are only supported starting with android 0 --min-api 26
How to convert milli seconds to hours, minutes and seconds in Android?
How to get a contact image using a phone number in android?
What is ANR in android?
Key Points to remember while develop the Android Application.
What happens next when the device switches between portrait and landscape?
How to install/ uninstall apk by command line ADB
How to convert DP to Pixel and Pixel to Dp?
What are Android Versions available?
Intent for Drive PDF Viewer - How to open PDF in Google Drive with intent
What are the notifications available in android?
Could not inflate Behavior subclass android.support.design.widget. BottomSheetBehavior How resolve
ERROR Android emulator gets killed when I try to run my application and choose an emulator it ret
How to add jar/library files as a dependency in Android studio gradle file
How to Generate signed apk with android studio
Android Studio project R can't find
How can i comment inside xml file in android studio?
How to stop EditText focus at Activity startup in Android?
Is There A Way To Get The Source Code From An APK File? (or) How to decompile apk?
Hide/Disable soft keyboard on Activity launch: Android
What is Context?
How to check Android version?
How to extract date and time from Long type variable in Kotlin on Android "
Android FCM not receiving notifications when app is removed from background