0
我想使用此代碼以編程方式更改佈局中的textView對齊方式。使用LayoutParams更改TextView的對齊方式不起作用
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)textView1.getLayoutParams();
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
textView1.setLayoutParams(params);
但是當我嘗試它RelativeLayout
沒有ALIGN_PARENT_RIGHT或generaly對齊_...我應該怎麼辦?
你叫'setLayoutParams'後'requestLayout'? – suitianshi
嘗試textView1.setGravity(RIGHT); – Arnab