Get height and width of a layout programmatically

前端 未结 16 1415
别那么骄傲
别那么骄傲 2020-11-27 13:55

I have designed an layout in which LinearLayout has 2 children LinearLayout and FrameLayout and in each child I put different views.

16条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-27 14:40

    For frame:

    height=fr.getHeight();
    width=fr.getWidth();
    

    For screen:

    width = getWindowManager().getDefaultDisplay().getWidth();
    height = getWindowManager().getDefaultDisplay().getHeight();
    

提交回复
热议问题