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;
ERR_ACCESS_DENIED in Android Webview with sdk 30
Open PDF in Google Drive with Intent in Android - RRutors
How do I check in SQLite whether a table exists?
How to stop EditText focus at Activity startup in Android?
What is Intent? What is the difference between an implicit intent and an explicit intent?
What is NetworkOnMainThread Exception?
What are the notifications available in android?
What is Android Fragments?
Symmetric vs Asymmetric Encryption in Android Server - RRutors
What is Context?
Explain Fragment Life Cycle
How to Exit android app on back pressed?
How to convert DP to Pixel and Pixel to Dp?
How to Generate signed apk with android studio
Hide/Disable soft keyboard on Activity launch: Android
What happens next when the device switches between portrait and landscape?
Decompile APK Files: How to Get Source Code - RRutors Guide
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
What is Application?
What is "shared preferences" in Android ?
How can i comment inside xml file in android studio?
Fix Duplicate Files in APK Build.gradle Issue - RRutors
FCM Not Receiving Notifications in Android - RRutors
How to save activity State in Android?
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
Check List for Generate Signed APK Android
How to get an image resource by it's name in android?
Fix Behavior Subclass BottomSheetBehavior Exception - RRutors
How to Get bitmap from drawable: Android
How To Set Text Color Programmatically Android TextView?
How to validate email address in Android with Kotlin?
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
Invoke-customs are only supported starting with android 0 --min-api 26
What is the Different Between val and var in Kotlin?
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
What is ANR in android?
How do i load image from drawable folder in Jetpack Compose?
Add Jar/Library Files as Dependency in Android Studio
What is Android?
Extract Date and Time from Long Type Variable - RRutors