我如何编写此代码:
protected void onCreate(Bundle savedInstanceState) {
Display display = getWindowManager().getDefaultDisplay();
Point screenSize = new Point();
display.getSize(screenSize);
Button button1 = (Button)findViewById(R.id.button1);
LayoutParams params = new LayoutParams(screenSize.x/3-(10*2), screenSize.x/3-(10*2));
button1.setLayoutParams(params);
}
在xml中?