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;
Explain Fragment Life Cycle
Fix Play Store Rejection Due to SMS Permission - RRutors
Open PDF in Google Drive with Intent in Android - RRutors
Symmetric vs Asymmetric Encryption in Android Server - RRutors
ERR_ACCESS_DENIED in Android Webview with sdk 30
How do I check in SQLite whether a table exists?
How to convert DP to Pixel and Pixel to Dp?
What are Android Versions available?
What is Context?
Fix Duplicate Files in APK Build.gradle Issue - RRutors
Key Points to remember while develop the Android Application.
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
How to check Android version?
How do i load image from drawable folder in Jetpack Compose?
What are the notifications available in android?
How to validate email address in Android with Kotlin?
Fix Android Emulator Kill Error When Running Your App
How to copy database from assets folder in android using kotlin
How To Set Text Color Programmatically Android TextView?
How to reduce APK package size?
How to avoid multiple button click at same time in android?
Decompile APK Files: How to Get Source Code - RRutors Guide
How to get an image resource by it's name in android?
How do I generate random numbers in Dart?
How to find Android Device UDID or unique ID?
What is Intent? What is the difference between an implicit intent and an explicit intent?
Fix Behavior Subclass BottomSheetBehavior Exception - RRutors
How to Generate signed apk with android studio
What is NetworkOnMainThread Exception?
How to get a contact image using a phone number in android?
How to Use Deprecated Handler() in Android - RRutors Guide
Android Studio project R can't find
How to Exit android app on back pressed?
How to convert milli seconds to hours, minutes and seconds in Android?
How to get complete address from latitude and longitude?
What is Android Fragments?
Permission denied for window type 2010 in Marshmallow device
What is "shared preferences" in Android ?
Check List for Generate Signed APK Android
FCM Not Receiving Notifications in Android - RRutors