tags:

views:

365

answers:

2

Hi,

I am trying to display a SpreadSheet in the Android application with auot adjustable columns and each columns should surrounded by lines.I used the Table Layout the data are displayed in the Table format but i dont know how to surround each column with lines, auto adjustment.If anyone knows it please help me.

+2  A: 

You can set a background color for the TableLayout and give your TableRows a margin:

<TableLayout android:background="#000000">
    <TableRow android:background="#ffffff" android:layout_margin="3dip">
    <!-- etc. -->
Josef
Thanks for the Reply,it will be useful while using XML,but i am adding TableRows through java code for dynamic layout purpose.you have any idea in java code
Rajapandian
You may use the `View`'s `setBackgroundColor` and `MarginLayoutParams.setMargins` to achieve the same in code.
Josef
+1  A: 

Use TableLayout.LayoutParams or TableRow.LayoutParams. They inherit ViewGroup.MarginLayoutParams, which you seem to need.

A sample code with TableRow.LayoutParams could be:

// you can also init values for width, height and weight here
TableRow.LayoutParams params = new TableRow.LayoutParams();
params.setMargins(LEFT_MARGIN, TOP_MARGIN, RIGHT_MARGIN, BOTTOM_MARGIN);

TextView textView = new TextView(this);
textView.setText("I'm in the table");

TableRow row = new TableRow();
row.addView(textView, params);

The same principle could be applied with TableLayout.LayoutParams, when you add to the table layout.

Dimitar Dimitrov
please can you give some code snippets
Rajapandian