Getting the size of the window WITHOUT title/notification bars

后端 未结 5 877
傲寒
傲寒 2021-02-07 04:19

I\'ve been playing around with Android development and one of the things I\'d like to be able to do is dynamically create a background image for my windows, similar to the one b

5条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-07 04:37

    Use View.MeasureSpec.getSize method in onMeasure override.

        @Override
    protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec)
    {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        int width = MeasureSpec.getSize(widthMeasureSpec);
        int height = MeasureSpec.getSize(heightMeasureSpec);
        ...
    }
    

提交回复
热议问题