Determining the size of an Android view at runtime

前端 未结 12 1743
陌清茗
陌清茗 2020-11-22 09:59

I am trying to apply an animation to a view in my Android app after my activity is created. To do this, I need to determine the current size of the view, and then set up an

12条回答
  •  感情败类
    2020-11-22 10:15

    Use below code, it is give the size of view.

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
           super.onWindowFocusChanged(hasFocus);
           Log.e("WIDTH",""+view.getWidth());
           Log.e("HEIGHT",""+view.getHeight());
    }
    

提交回复
热议问题