Setting width to wrap_content for TextView through code

后端 未结 6 1454
我在风中等你
我在风中等你 2020-12-25 09:24

Can anyone help me how to set the width of TextView to wrap_content through code and not from XML?

I am dynamically creating a TextVi

6条回答
  •  忘掉有多难
    2020-12-25 09:40

    I think this code answer your question

    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) 
    holder.desc1.getLayoutParams();
    params.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
    holder.desc1.setLayoutParams(params);
    

提交回复
热议问题