• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps TableLayout problem

tmlder

Lurker
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:
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
 
Back
Top Bottom