我们如何在java代码中更改按钮大小

adi*_*thi 2 android button

我在 java 代码中创建了按钮,但无法更改按钮的大小。我使用了

            btn = new Button(Activity.this);
    btn.setText("\t\t" + lbl + "\t\t\t  ");
            btn.setBackgroundResource(R.drawable.blue_button);
    btn.setwidth(100);
Run Code Online (Sandbox Code Playgroud)

但没有用。知道吗?谢谢

Dha*_*dra 5

 btn = new Button(Activity.this);
btn.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    btn.setText("\t\t" + lbl + "\t\t\t  ");
            btn.setBackgroundResource(R.drawable.blue_button);
    btn.setwidth(100);
Run Code Online (Sandbox Code Playgroud)