Android Button サイズの設定 コード

import android.widget.LinearLayout;

LinearLayout.LayoutParams buttonLayoutParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);

final ImageButton button1 = (ImageButton) findViewById(R.id.button1);
button1.setScaleType(ImageButton.ScaleType.FIT_XY);

int buttonWidth = (int)(100);
int buttonHeight = (int)(100);

buttonLayoutParams = new LinearLayout.LayoutParams(buttonWidth, buttonHeight);
button1.setLayoutParams(buttonLayoutParams);

いいなと思ったら応援しよう!