How to Change Margin of TextView

前端 未结 8 1830
感动是毒
感动是毒 2020-12-04 13:11

I have TextView added Programmatically in to LinearLayout and on some external events I want to decrease bottom margin of that TextView to -10, for that I tried following. <

8条回答
  •  一整个雨季
    2020-12-04 13:47

    setMargins() sets the INNER margins of the TextView, not the layout-margins. Is that what you want to do? This two different margins can be quite complicated.

    If you want to set the layout margins, change the LayoutParams of the TextView (textview.getLayoutParams(), then change the parameters on the returned LayoutParams object).

    You don't need to change anything on your LinearLayout.

    Regards, Oliver

提交回复
热议问题