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;
What is Android Fragments?
What is ANR? How to avoid and resolve it?
What is ANR in android?
What is Android?
How to install/ uninstall apk by command line ADB
How to reduce APK package size?
Extract Date and Time from Long Type Variable - RRutors
What are the notifications available in android?
How to save activity State in Android?
How To Set Text Color Programmatically Android TextView?
Hide/Disable soft keyboard on Activity launch: Android
Android Studio project R can't find
How to get complete address from latitude and longitude?
What is Application?
How to stop EditText focus at Activity startup in Android?
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
How do I generate random numbers in Dart?
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
How do I check in SQLite whether a table exists?
How to convert milli seconds to hours, minutes and seconds in Android?
Decompile APK Files: How to Get Source Code - RRutors Guide
Check List for Generate Signed APK Android
What happens next when the device switches between portrait and landscape?
What are Android Versions available?
How to Get bitmap from drawable: Android
ERR_ACCESS_DENIED in Android Webview with sdk 30
Fix Play Store Rejection Due to SMS Permission - RRutors
What is Context?
What is the difference between match_parent and fill_parent?
How to get an image resource by it's name in android?
Set Activity to Fullscreen Mode in Android - RRutors
Open PDF in Google Drive with Intent in Android - RRutors
Explain Fragment Life Cycle
How to copy database from assets folder in android using kotlin
How to validate email address in Android with Kotlin?
How to Generate signed apk with android studio
How to get screen size (width,height) in Android?
How to check Android version?
Key Points to remember while develop the Android Application.