我的問題很簡單,如何以編程方式設置按鈕layout_gravity?我在互聯網上找到了它,但它只是拋出了一個Nullpointer異常: Button MyButton = new Button(this); LinearLayout.LayoutParams lllp=(LinearLayout.LayoutParams)MyButton.getLayoutParams(); lllp.gravity=Gravity.RIGHT; MyButton.setLayoutParams(lllp); MyLinearLayout.addView(MyButton);有什么辦法嗎?
- 3 回答
- 0 關注
- 976 瀏覽
添加回答
舉報
0/150
提交
取消