Android getMeasuredHeight returns wrong values !

后端 未结 7 694
野的像风
野的像风 2020-12-02 20:13

I\'m trying to determine the real dimension in pixels of some UI elements !

Those elements are inflated from a .xml file and are initialized with dip width and height

7条回答
  •  鱼传尺愫
    2020-12-02 20:35

    Do that:

    frame.measure(0, 0);
    
    final int w = frame.getMeasuredWidth();
    final int h = frame.getMeasuredHeight();
    

    Solved!

提交回复
热议问题