How to retrieve the dimensions of a view?

前端 未结 16 1681
小蘑菇
小蘑菇 2020-11-22 01:09

I have a view made up of TableLayout, TableRow and TextView. I want it to look like a grid. I need to get the height and width of this grid. The methods

16条回答
  •  囚心锁ツ
    2020-11-22 01:25

    Use the View's post method like this

    post(new Runnable() {   
        @Override
        public void run() {
            Log.d(TAG, "width " + MyView.this.getMeasuredWidth());
            }
        });
    

提交回复
热议问题