February 5th, 2012, 07:47 AM
|
#1 (permalink)
|
|
New Member
Join Date: Dec 2010
Posts: 8
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
|
TableLayout problem
I need to create table layout with 2 cells (2 ImageButton) that equals and fit to full screen by height and width.
I tried differents options, params, but I can't create it.
My code:
PHP Code:
TableLayout tl = (TableLayout) findViewById(R.id.colorLayout);
// tl.setBackgroundColor(Color.RED);
TableRow row = new TableRow(this);
row.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
row.setGravity(Gravity.FILL);
row.setBackgroundColor(Color.BLUE);
// row.setMinimumHeight(100);
// row.setMinimumWidth(100);
ImageButton img = new ImageButton(this);
img.setBackgroundColor(Color.RED);
// img.setScaleType(ScaleType.FIT_XY);
// img.setLayoutParams(new TableLayout.LayoutParams(
// LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
img.setMinimumHeight(100);
img.setMinimumWidth(100);
ImageButton img2 = new ImageButton(this);
img2.setBackgroundColor(Color.WHITE);
img2.setMinimumHeight(100);
img2.setMinimumWidth(100);
// img2.setScaleType(ScaleType.FIT_XY);
// img2.setLayoutParams(new TableLayout.LayoutParams(
// LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
row.addView(img);
row.addView(img2);
// row.addView(img, new TableLayout.LayoutParams(
// LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
// row.addView(img2, new TableLayout.LayoutParams(
// LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
tl.addView(row, new TableLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
return;
whats wrong? Help me
|
|
|