Can't get height of Widgets

前端 未结 2 1676
清歌不尽
清歌不尽 2021-01-24 02:05

I am facing a problem when gets height/width of TextView.

My code :

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(saved         


        
2条回答
  •  不知归路
    2021-01-24 02:38

    View.getWidth()/View.getHeight() won't give you a meaningful answer until the view has been measured. Read about how android draws views here.
    See this thread to get an idea of when the measured dimensions will be available.

提交回复
热议问题