android - setting LayoutParams programmatically

前端 未结 5 1052
南笙
南笙 2020-11-29 03:00

I putting an in-game chat module into an app. I am adding text messages as they are received into a LinearLayout view. I want to set the layout params to the TextView but th

5条回答
  •  鱼传尺愫
    2020-11-29 04:00

      LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(
                       /*width*/ ViewGroup.LayoutParams.MATCH_PARENT,
                       /*height*/ ViewGroup.LayoutParams.MATCH_PARENT,
                       /*weight*/ 1.0f
                );
                YOUR_VIEW.setLayoutParams(param);
    

提交回复
热议问题