How to find the Width of the a view before the view is displayed?

前端 未结 6 567
耶瑟儿~
耶瑟儿~ 2020-12-14 01:07

How to find the Width of the a view before the view is displayed? I do not want to add a custom view and tap the dimensions in the OnChanged().

6条回答
  •  遥遥无期
    2020-12-14 01:10

    This is the best way...... WORK!!!

    public void onWindowFocusChanged(boolean hasFocus) {          
      super.onWindowFocusChanged(hasFocus);
    
      if (fondo_iconos_height==0) { // to ensure that this does not happen more than once
          fondo_iconos.getLocationOnScreen(loc);
          fondo_iconos_height = fondo_iconos.getHeight();
          redraw_function();
      }
    
     }
    

提交回复
热议问题