我能够控制高度,但不知何故它对按钮宽度没有任何影响。
// Table Row for Previous button
TableRow tableRow1 = new TableRow(this);
tableRow1.setLayoutParams(new TableRow.LayoutParams(
TableRow.LayoutParams.WRAP_CONTENT,
TableRow.LayoutParams.WRAP_CONTENT));
tableRow1.setPadding(5, 5, 5, 5);
// Button - Previous
Button btnPrev = new Button(this);
btnPrev.setText("< Previous");
btnPrev.setGravity(Gravity.CENTER);
btnPrev.setOnClickListener(prevListener);
tableRow1.addView(btnPrev);
android.view.ViewGroup.LayoutParams params = btnPrev.getLayoutParams();
params.height = 20;
params.width = 60;
btnPrev.setLayoutParams(params);
// TextView for Previous button
TextView textView11 = new TextView(this);
textView11.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
textView11.setGravity(Gravity.CENTER_VERTICAL);
textView11.setGravity(Gravity.RIGHT);
textView11.setPadding(0, 0, 20, 0);
textView11.setText("New Entry Form");
tableRow1.addView(textView11);
android.view.ViewGroup.LayoutParams params1 = textView11
.getLayoutParams();
params1.height = (int) dipHeight;
textView11.setLayoutParams(params1);
tableLayout.addView(tableRow1);
我试着在这里和那里改变一些东西,但没有看。
你的某个人可以花点时间帮助我吗?