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;
Hide/Disable soft keyboard on Activity launch: Android
What is the Different Between val and var in Kotlin?
What are Android Versions available?
What is ANR? How to avoid and resolve it?
How to get complete address from latitude and longitude?
Check List for Generate Signed APK Android
What is ANR in android?
What is the difference between match_parent and fill_parent?
What is "shared preferences" in Android ?
How to validate email address in Android with Kotlin?
How to find Android Device UDID or unique ID?
What is Android?
How To Set Text Color Programmatically Android TextView?
How can i comment inside xml file in android studio?
Add Jar/Library Files as Dependency in Android Studio
How to get an image resource by it's name in android?
Key Points to remember while develop the Android Application.
How do I generate random numbers in Dart?
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
What happens next when the device switches between portrait and landscape?
How to Use Deprecated Handler() in Android - RRutors Guide
Permission denied for window type 2010 in Marshmallow device
What is Application?
How to get a contact image using a phone number in android?
How to Exit android app on back pressed?
How to start a new activity on button click
Fix Duplicate Files in APK Build.gradle Issue - RRutors
How do i load image from drawable folder in Jetpack Compose?
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
How to reduce APK package size?
Symmetric vs Asymmetric Encryption in Android Server - RRutors
Fix Play Store Rejection Due to SMS Permission - RRutors
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
How to check Android version?
Invoke-customs are only supported starting with android 0 --min-api 26
What are the notifications available in android?
How to install/ uninstall apk by command line ADB
What is Intent? What is the difference between an implicit intent and an explicit intent?
What is Context?
How to save activity State in Android?