How to make Table Layout Screen independent
<p>1.This is my code where i m trying to display a matrix of buttons with the help of    table layout .and i have also tried to make this matrix screen independent but this is not working properly.in large size emulator it is giving problem buttons getting overlapped.</p>

<pre><code>     TableLayout layout = new TableLayout (this);
     layout.setStretchAllColumns(true);
     Display display = ((WindowManager)       getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
           int width = display.getWidth();  
           int height = display.getHeight();
           layout.setLayoutParams( new TableLayout.LayoutParams(height,width) );

            layout.setPadding(1,1,1,1);

            for (int f=0; f&lt;=3; f++) 
            {
                TableRow tr = new TableRow(this);

                for (int c=0; c&lt;=3; c++) 
                {
                    Button b = new Button (this);
                    b.setText(""+f+c);
                    b.setTextSize(10.0f);
                    b.setTextColor(Color.rgb( 100, 200, 200));



                  tr.addView(b,30,30);


                    final float scale = getBaseContext().getResources().getDisplayMetrics().density;
                    int pixels = (int) (dps * scale + 0.5f);
                     b.setHeight(pixels);
                     b.setWidth(pixels);


                } // for
                layout.addView(tr);
            } // for

            super.setContentView(layout);
        } 

        }
</code></pre>
