If you want the the display dimensions in pixels you can use getSize: Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); int width = size.x; int height = size.y; If you're not in an Activity you can get the default Display via WINDOW_SERVICE: WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Before getSize was introduced (in API level ), you could use the getWidth and getHeight methods that are now deprecated: Display display = getWindowManager().getDefaultDisplay(); int width = display.getWidth(); // deprecated int height = display.getHeight(); // deprecated
推荐整理分享display getSize(),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:,内容如对您有帮助,希望把文章链接给更多的朋友!
安卓学习3-布局管理-TableLayout API:
动态设置布局LayoutInflater LayoutInflater作用是将layout的xml布局文件实例化为View类对象,LayoutInflater的作用类于findViewById(),不同点是LayoutInflater是用来找layout文件夹下的xml布局文件,
欢迎使用CSDN-markdown编辑器 androidstudio编译报错:Error:(xx,x)Couldnotfindproperty'processResources'oncom.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated@xxxxxxx.解决方法:将app下的build.gradle