国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

And,roid中獲得手機屏幕大小實現代碼

2019-11-02 15:17:19
字體:
來源:轉載
供稿:網友

   這篇文章主要介紹了Android中獲得手機屏幕大小實現代碼,Android開發中經常需要獲得屏幕的寬高,本文直接封裝成一個工具類,需要的朋友可以參考下

  Android在自定義控件時,經常需要獲得屏幕的寬高,每次都要寫,不妨直接把他封裝成工具類,直接拿來用,廢話不說,直接上代碼

  ?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 /** * */ package com.example.customview;   import android.content.Context; import android.util.DisplayMetrics; import android.view.WindowManager;   /** * 獲取手機屏幕大小 * @author * */ public class MeasureUtil {   /** * 寬 * @return */ public static int getWidth(Context context){ WindowManager wm=(WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics outMetrics = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(outMetrics); return outMetrics.widthPixels; }   /** * 高 * @return */ public static int getHeight(Context context){ WindowManager wm=(WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics outMetrics = new DisplayMetrics(); wm.getDefaultDisplay().getMetric
搞笑動態圖片[www.62-6.com/1/pic/]
s(outMetrics); return outMetrics.heightPixels; }   }
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 昌平区| 杨浦区| 乌什县| 丰宁| 滨海县| 阜阳市| 越西县| 政和县| 大安市| 玉门市| 罗定市| 梓潼县| 泰宁县| 屯门区| 安塞县| 千阳县| 安徽省| 阿瓦提县| 罗田县| 阳谷县| 凤庆县| 琼中| 县级市| 治县。| 揭东县| 察隅县| 沙坪坝区| 兴仁县| 石泉县| 抚远县| 榆中县| 大丰市| 锦州市| 蒙阴县| 尉氏县| 自贡市| 阳城县| 六枝特区| 枣庄市| 太白县| 襄樊市|