Android get programmatically created view's width

前端 未结 5 2115
一生所求
一生所求 2021-02-18 16:48

I have TextView created programmatically, like that:

                TextView mTextView = new TextView(getApplicationContext());

                final LayoutPar         


        
5条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-18 17:32

    get this way:

    tV.post(new Runnable() {
                        @Override
                        public void run() {
                            int width=tV.getMeasuredWidth();
                        }
                    });
    

提交回复
热议问题