How to set size and layout in onSizeChanged?

前端 未结 4 1286
孤城傲影
孤城傲影 2020-12-25 11:39

I can\'t get my elements, for example ListView, to resize properly.

I got a ListActivity for searching, with a dashboard, an editbox and a

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-25 12:37

    Adding the following at the end of onSizeChanged() will solve it:

    Handler handler = new Handler();
    handler.post(new Runnable() {
    
        @Override
        public void run() {
            requestLayout();
        }
    });
    

    See the answer to this question: Views inside a custom ViewGroup not rendering after a size change

提交回复
热议问题