[Android] Set LayoutParams Programmatically

  • 0
* 注意:如果要保險的話,就使用 new LayoutParams(int width, int height), 盡量不要用getLayoutParams()

TextView margin
lp.setMargins(50, 0, 0, 0); // lp.setMargins(left, top, right, bottom);

* RelativeLayout: toLeftOf, toRightOf, below
lp.addRule(RelativeLayout.RIGHT_OF, R.id.my_view); 

alignParentLeft, alignParentTop, alignParentRight, alignParentBottom
lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

沒有留言 :

張貼留言