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
How To Set Text Color Programmatically Android TextView?
Add Jar/Library Files as Dependency in Android Studio
What is the Different Between val and var in Kotlin?
How to get a contact image using a phone number in android?
Fix Duplicate Files in APK Build.gradle Issue - RRutors
How to stop EditText focus at Activity startup in Android?
ERR_ACCESS_DENIED in Android Webview with sdk 30
Key Points to remember while develop the Android Application.
Decompile APK Files: How to Get Source Code - RRutors Guide
What happens next when the device switches between portrait and landscape?
How to reduce APK package size?
How to avoid multiple button click at same time in android?
What is Android?
Hide/Disable soft keyboard on Activity launch: Android
How to get screen size (width,height) in Android?
What is NetworkOnMainThread Exception?
How to install/ uninstall apk by command line ADB
Check List for Generate Signed APK Android
How to Exit android app on back pressed?
Set Activity to Fullscreen Mode in Android - RRutors
Symmetric vs Asymmetric Encryption in Android Server - RRutors
Extract Date and Time from Long Type Variable - RRutors
How do I generate random numbers in Dart?
What is Android Fragments?
How do i load image from drawable folder in Jetpack Compose?
What are the notifications available in android?
Permission denied for window type 2010 in Marshmallow device
What is Application?
How to Use Deprecated Handler() in Android - RRutors Guide
Fix Play Store Rejection Due to SMS Permission - RRutors
What is ANR in android?
Fix Behavior Subclass BottomSheetBehavior Exception - RRutors
What is the difference between match_parent and fill_parent?
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
How can i comment inside xml file in android studio?
How to check Android version?
What is Intent? What is the difference between an implicit intent and an explicit intent?
How to find Android Device UDID or unique ID?
Open PDF in Google Drive with Intent in Android - RRutors