You’ll have to convert it from dps to pixels using the display scale factor.
final float scale = getContext().getResources().getDisplayMetrics().density;
int pixels = (int) (dps * scale + 0.5f);
More Related Contents:
- Android Webview – Webpage should fit the device screen
- Why isn’t my vector drawable scaling as expected?
- What does the filter parameter to createScaledBitmap do?
- Scaled Bitmap maintaining aspect ratio
- Android imageview not respecting maxWidth?
- Get Canvas coordinates after scaling up/down or dragging in android
- How to use getdownloadurl in recent versions?
- Communication between Android Java and Phonegap Javascript?
- How to change action bar size
- how to prevent system font-size changing effects to android application?
- Android BOOT_COMPLETED not received when application is closed
- How can I display Album Art using MediaStore.Audio.Albums.ALBUM_ART?
- SSLHandshakeException: Handshake failed on Android N/7.0
- Unable to resolve target ‘android-XX’
- Installing ADB on macOS [duplicate]
- Fragment transaction animation: slide in and slide out
- OutofMemoryError: bitmap size exceeds VM budget (Android)
- How to get current buildType in Android Gradle configuration
- How do I read properties defined in local.properties in build.gradle
- How do you remove the title text from the Android ActionBar?
- Do GCM registration id’s expire?
- Android: OutofMemoryError: bitmap size exceeds VM budget with no reason I can see
- How do I properly fire ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS intent?
- Using NumberPicker Widget with Strings
- Android – Open target _blank links in WebView with external browser
- Debugging Android NDK C/C++ code in Eclipse – breakpoints are not hit
- How to change the star images of the RatingBar?
- Android Emulator: This app won’t run without Google Play services
- Java.lang.ClassNotFoundException after Android studio update
- Android:How to upload .mp3 file to http server?