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;
How to extract date and time from Long type variable in Kotlin on Android "
How do I generate random numbers in Dart?
What is the difference between match_parent and fill_parent?
How do I check in SQLite whether a table exists?
How to Get bitmap from drawable: Android
What happens next when the device switches between portrait and landscape?
How to Generate signed apk with android studio
What are Android Versions available?
ERROR Android emulator gets killed when I try to run my application and choose an emulator it ret
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
Key Points to remember while develop the Android Application.
Could not inflate Behavior subclass android.support.design.widget. BottomSheetBehavior How resolve
How to convert DP to Pixel and Pixel to Dp?
What are the notifications available in android?
Error: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path
What is ANR in android?
Android Activity FullScreen - How to set activity to fullscreen mode in Android?
What is Android Fragments?
'constructor Handler()' is deprecated. Deprecated in Java, How to use Handler() class in And
How to reduce APK package size?
Android Studio project R can't find
How to get a contact image using a phone number in android?
Google play store rejected my app due to SMS permission I removed SMS permission from the manifes
How to get screen size (width,height) in Android?
What is Intent? What is the difference between an implicit intent and an explicit intent?
Duplicate files during packaging of APK” build.gradle issue: Android Studio
How to find Android Device UDID or unique ID?
What are symmetric and asymmetric encryption in the way Android interacts with the server?
How can i comment inside xml file in android studio?
How to save activity State in Android?
How to validate email address in Android with Kotlin?
How to stop EditText focus at Activity startup in Android?
How to convert milli seconds to hours, minutes and seconds in Android?
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
Is There A Way To Get The Source Code From An APK File? (or) How to decompile apk?
How to get an image resource by it's name in android?
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
Check List for Generate Signed APK Android
What is ANR? How to avoid and resolve it?
Permission denied for window type 2010 in Marshmallow device