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;
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
How to Use Deprecated Handler() in Android - RRutors Guide
How to reduce APK package size?
How to get complete address from latitude and longitude?
Hide/Disable soft keyboard on Activity launch: Android
What is NetworkOnMainThread Exception?
How do i load image from drawable folder in Jetpack Compose?
Add Jar/Library Files as Dependency in Android Studio
How to find Android Device UDID or unique ID?
Set Activity to Fullscreen Mode in Android - RRutors
Fix Behavior Subclass BottomSheetBehavior Exception - RRutors
What is ANR in android?
What is the Different Between val and var in Kotlin?
What are the notifications available in android?
Explain Fragment Life Cycle
Decompile APK Files: How to Get Source Code - RRutors Guide
How do I check in SQLite whether a table exists?
Invoke-customs are only supported starting with android 0 --min-api 26
How to get screen size (width,height) in Android?
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
ERR_ACCESS_DENIED in Android Webview with sdk 30
Fix Android Emulator Kill Error When Running Your App
What is "shared preferences" in Android ?
Extract Date and Time from Long Type Variable - RRutors
How to check Android version?
Android Studio project R can't find
How To Set Text Color Programmatically Android TextView?
How to Get bitmap from drawable: Android
How can i comment inside xml file in android studio?
What is Intent? What is the difference between an implicit intent and an explicit intent?
What is Application?
What is Android?
Fix Play Store Rejection Due to SMS Permission - RRutors
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
What is ANR? How to avoid and resolve it?
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
What are Android Versions available?
What is the difference between match_parent and fill_parent?
How to avoid multiple button click at same time in android?
How do I generate random numbers in Dart?