add view to relativelayout programmatically

Solutions on MaxInterview for add view to relativelayout programmatically by the best coders in the world

showing results for - "add view to relativelayout programmatically"
Nicolò
17 Mar 2019
1TextView tv = new TextView(mContext);
2RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
3    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
4params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
5params.leftMargin = 107
6...
7mRelativeLayout.addView(tv, params);