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.
Could not inflate Behavior subclass android.support.design.widget. BottomSheetBehavior How resolve
How to add jar/library files as a dependency in Android studio gradle file
What happens next when the device switches between portrait and landscape?
Android Activity FullScreen - How to set activity to fullscreen mode in Android?
What is Android?
How do I generate random numbers in Dart?
How do I check in SQLite whether a table exists?
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
What is "shared preferences" in Android ?
How to convert DP to Pixel and Pixel to Dp?
How to Generate signed apk with android studio
How to avoid multiple button click at same time in android?
Duplicate files during packaging of APK” build.gradle issue: Android Studio
What are the notifications available in android?
How to install/ uninstall apk by command line ADB
How to Get bitmap from drawable: Android
Invoke-customs are only supported starting with android 0 --min-api 26
ERR_ACCESS_DENIED in Android Webview with sdk 30
How to stop EditText focus at Activity startup in Android?
How to extract date and time from Long type variable in Kotlin on Android "
How to reduce APK package size?
Error: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path
Android FCM not receiving notifications when app is removed from background
How do i load image from drawable folder in Jetpack Compose?
What is ANR? How to avoid and resolve it?
Hide/Disable soft keyboard on Activity launch: Android
What is the Different Between val and var in Kotlin?
What is the difference between match_parent and fill_parent?
What is NetworkOnMainThread Exception?
How to validate email address in Android with Kotlin?
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
How to convert milli seconds to hours, minutes and seconds in Android?
How to check Android version?
What is ANR in android?
How to copy database from assets folder in android using kotlin
'constructor Handler()' is deprecated. Deprecated in Java, How to use Handler() class in And
Check List for Generate Signed APK Android
What is Context?
How to find Android Device UDID or unique ID?