プログラムでボタンオブジェクトに左マージンを設定する必要があります。これはコードセグメントです:
RelativeLayout rl = (RelativeLayout) findViewById(R.id.for_button);
MarginLayoutParams ml = new MarginLayoutParams(-2,-2);
ml.setMargins(5, 0, 0, 0);
Button btn = new Button(this);
btn.setText("7");
btn.setTextColor(Color.WHITE);
btn.setBackgroundResource(R.drawable.date_button);
rl.addView(btn,ml)
私も試しました
btn.setLayoutParams(ml);
rl.addView(btn);
大きな問題は何ですか。または、別の方法はありますか?