如何确定一个Android View的像素大小? [英] How to determine an Android View's size in pixels?

查看:172
本文介绍了如何确定一个Android View的像素大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有直接的编程方式来获得FILL_PARENT查看的像素高度和宽度?比如在一个选项卡网格布局的视图。还是我得到窗口的大小和减去它周围的景色静态大小?

Is there a direct programmatic way to get a fill_parent View's pixel height and width? For instance a view in a grid layout in a tab. Or do I have to get the window size and subtract the static sizes of the views around it?

推荐答案

您可以通过调用得到的意见父 myView.getParent()的getWidth()的getHeight()您获得您所需要的像素。
该文档这个话题提供更多信息
<一href=\"http://developer.android.com/reference/android/view/View.html\">http://developer.android.com/reference/android/view/View.html

You can get the views parent by calling myView.getParent() and with getWidth() and getHeight() you get the pixel you need. the documentation is providing more information to this topic http://developer.android.com/reference/android/view/View.html

这篇关于如何确定一个Android View的像素大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆