如何确定一个Android View的像素大小?像素、大小、Android、View

2023-09-07 15:20:09 作者:七秒钟的记忆

有没有直接的编程方式来获得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()您获得您所需要的像素。该文档这个话题提供更多信息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