如果我有5英寸對角線屏幕尺寸和2.3英寸屏幕寬度的Android設備,並且它的屏幕支持1080 * 1920像素,那麼屏幕密度最接近的類型是什麼?如何解決這個問題?Android中的像素密度
3
A
回答
2
字體大小應該使用sp
,其他任何使用dp
。看到這個SO張貼關於屏幕密度,術語和適當的用途:Difference between px, dp, dip and sp in Android?
而且,這裏是Android開發人員的API指南的鏈接在您的應用程序支持多種屏幕:http://developer.android.com/guide/practices/screens_support.html
1
你可以找出設備顯示器信息從活動
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int dpi = dm.densityDpi;
dm.densityDpi
閱讀DisplayMetrics會給你點每英寸
你可以ALS表示設備DPI桶Ø得到其他顯示指標,如:
float density - The logical density of the display - scaling factor
float scaledDensity - A scaling factor for fonts displayed on the display.
int widthPixels - The absolute width of the display in pixels.
int heightPixels - The absolute height of the display in pixels.
float xdpi - Physical pixels per inch of the screen in the X dimension.
float ydpi - Physical pixels per inch of the screen in the Y dimension.
但是,對於某些設備xdpi
和ydpi
度量返回錯誤的號碼,你不能依靠他們。由於API 17,您也可以使用getRealMetrics()
。它應該給你準確的值xdpi
和ydpi
。
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getRealMetrics(dm);
相關問題
- 1. CSS中的像素與像素密度
- 2. android定義密度獨立像素
- 3. Android:如何計算像素密度
- 4. Libgdx支持所有Android像素密度
- 5. iPhone的像素密度
- 6. Android的圖像,密度和
- 7. Android:如何在代碼中使用dip(密度獨立像素)?
- 8. LED像素密度,LED像素的高度和寬度,分辨率
- 9. Html Canvas在不同的像素密度
- 10. 旋轉時的低像素密度UIImage
- 11. 如何將像素轉換爲傾角(密度獨立像素)Android
- 12. Android:使用具有不同像素密度的圖像的目的?
- 13. Android:如何覆蓋密度並只使用像素?
- 14. 素數的密度:
- 15. Velocity Tracker佔屏幕像素密度
- 16. 密度(從傾角到像素)
- 17. PPI像素密度新混淆
- 18. ViewConfiguration.getScaledTouchSlop返回像素或DP(密度獨立像素)?
- 19. Android Apps中的密度
- 20. Android上的密度
- 21. 使用srcset和大小指定像素密度的圖像
- 22. 如何計算採樣二進制圖像的像素密度
- 23. React Native - 像素密度的圖像大小?
- 24. Pandas系列圖()中figsize的像素密度/ DPI是多少?
- 25. Android Studio密度
- 26. opencv中的像素強度#
- 27. 在android中以不同密度顯示的圖像
- 28. 灰度圖像中像素的質心
- 29. 最大密度的圖像
- 30. Android中的像素處理