Q:

Gridview button configuration

I have a Gridview displaying buttons that get their content from an array, please see below:
xml:
<LinearLayout
    android:background="@raw/br_poster_dark"
    android:orientation="vertical"    
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    android:layout_gravity="center"
    android:padding="30dip"     >   

            <GridView android:id="@+id/brgrid"
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent"
                android:padding="5dp"
                android:columnWidth="90dp"
                android:rowHeight="90dp"
                android:numColumns="3"
                android:gravity="center"
                android:textColor="#ffffff"
                />

</LinearLayout>

And the java for the buttons:
public View getView(int position, View convertView, ViewGroup parent) {
    try {
        final Sample sample = board.getSamples().get(position);

        if (sample != null) {
            Button button = new Button(context);
            button.setText(sample.getName());

            button.setBackgroundResource(R.drawable.roundedbutton);

As you can see I have a custom background (transparent gradient and rounded corners), which works fine, but I'm having great difficulty changing the other properties of the button, as most of the code would usually go into xml under "Button": 
For example, changing the colour of the text does not work, changing the row/column size under the GridView xml has no effect...
I would also like to have it display an evenly spaced grid with uniform button sizes instead of wrapping the text passed to the buttons and cramming them towards the top of the screen.
Is there a way I can create an xml button to be used by the Gridview?
Thanks in advance.

A:

I found a way to set the text size and layout of the button using the density scale:
button.setLayoutParams(new GridView.LayoutParams((int)(80 * densityScale + 0.5f), (int)(50 * densityScale + 0.5f)));

button.setTextSize(12);

