Programatically changing Textview height and width

后端 未结 3 456
梦谈多话
梦谈多话 2021-01-29 00:02

I have a textview that I want to change the width to match_parent and height to remain at wrap_content. It is nested within a horizontal linearlayout. It is the 2nd in 3 textvie

3条回答
  •  被撕碎了的回忆
    2021-01-29 00:12

    What is your TextView parent layout? Linear, Relative or what? Sample if LinearLayout:

    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    homeButton.setLayoutParams(params);
    

    You must create param base on its parent layout.

提交回复
热议问题