Android动态添加右边对齐按钮Demo,主要代码:LinearLayout linearLayout=new LinearLayout(this);
linearLayout.setGravity(Gravity.RIGHT);
Button button=new Button(this);
button.setText("按钮一");
linearLayout.addView(button);
button=new Button(this);
button.setText("按钮二");
linearLayout.addView(button);
mLinearLayoutTest.addView(linearLayout);
1