You might try adding margin to the children views using android:layout_marginRight or similar attributes.
j On Mon, Jun 1, 2009 at 2:59 AM, Muhammad Bilal <[email protected]> wrote: > > Hi i am just developing application in android . i am building a test > game TicTacToe . i am generating the GUI Programmatically i know i > can develop the same gui using xml but again i am doing this for > learning . > okay , i have created a TableLayout and add three TableRows in it and > each row i have created three buttons to create tictactoe interface . > the problem i am facing is that when i add buttons in column in table > row and run it there is no spacing between buttons. i have also use > setPadding() method but it adds spacing around the whole row not in > between columns , > > please help me resolving this issue , am i missing something thanks .. > i just was that i can't attached the image in the post , why is > that ..? > waiting anxiously for reply . > > here is the code > ----------------------------------------------------------------------------------- > package org.cprods.tictactoe; > > import android.app.Activity; > import android.graphics.Color; > import android.os.Bundle; > import android.view.Gravity; > import android.view.View; > import android.view.ViewGroup; > import android.view.Window; > import android.view.WindowManager; > import android.view.ViewGroup.LayoutParams; > import android.widget.Button; > import android.widget.TableLayout; > import android.widget.TableRow; > > public class GameScreen extends Activity{ > > > private TableLayout gameTable=null; > private Button gameButtons[][]=null; > private TableRow rows[]=null; > > �...@override > protected void onCreate(Bundle savedInstanceState) { > // TODO Auto-generated method stub > super.onCreate(savedInstanceState); > > gameTable=new TableLayout(this); > // gameTable.setGravity(Gravity.CENTER_HORIZONTAL); > gameTable.setBackgroundColor(Color.BLACK); > LayoutParams param=new LayoutParams > (LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT); > gameTable.setLayoutParams(param); > // gameTable.getLayoutParams > ().height=ViewGroup.LayoutParams.FILL_PARENT; > // gameTable.getLayoutParams > ().width=ViewGroup.LayoutParams.FILL_PARENT; > gameTable.setStretchAllColumns(true); > gameButtons=new Button[3][3]; > rows=new TableRow[3]; > int count=1; > for(int i=0;i<3;i++) > { > rows[i]=new TableRow(this); > rows[i].setPadding(5,5,5,5); > // rows[i].setLayoutParams(new LayoutParams > (LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT)); > > > for(int j=0;j<3;j++){ > gameButtons[i][j]=new Button(this); > // > gameButtons[i][j].setWidth((getWindowManager().getDefaultDisplay > ().getWidth()/3-30)); > // > gameButtons[i][j].setHeight((getWindowManager().getDefaultDisplay > ().getHeight()/3-30)); > gameButtons[i][j].setWidth(75); > gameButtons[i][j].setHeight(75); > > gameButtons[i][j].setBackgroundColor(Color.WHITE); > > //gameButtons[i][j].setGravity(Gravity.CENTER_HORIZONTAL | > Gravity.BOTTOM); > gameButtons[i][j].setText(""+count); > rows[i].setGravity(Gravity.CENTER_HORIZONTAL | > Gravity.BOTTOM); > rows[i].addView(gameButtons[i][j]); > //rows[i]. > count++; > } > gameTable.addView(rows[i]); > } > setContentView(gameTable); > gameTable.postInvalidate(); > > > > > } > } > > > > > > > -- Jeff Sharkey [email protected] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

