實例:


package com.AndroidButtonSize;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
public class AndroidButtonSizeActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Button button = (Button)findViewById(R.id.button);
button.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
LayoutParams params = button.getLayoutParams();
params.width = 300;
params.height = 200;
button.setLayoutParams(params);
}});
}
}
沒有留言:
發佈留言