1

In my application i am creating and displaying a table at runtime. The table is developed in an Activity class. Everything working fine, only issue is the view of the table. There are four textviews in a row in the table. they are shown adjacently without seperation. How could i make a proper view with a definite space between textviews.

            text1.setText("24/02/2011"); //TextView text
            text2.setText("Andy");       //TextView text
            text3.setText("3");          //TextView text
            text4.setText("Repeat");     //TextView text
            tableRow.addView(text1);     //TableRow tableRow
            tableRow.addView(text2);     //TableRow tableRow
            tableRow.addView(text3);     //TableRow tableRow
            tableRow.addView(text4);     //TableRow tableRow
            dueTL.addView(tableRow);     //TableLayout dueTL

It display the data like : 24/02/2011Andy3Repeat

4

3 回答 3

1

您可以添加weight到每个TextView,还请确保您TableViewfill_parent宽度有。还要检查s的paddingmarginsTextView

我希望这有帮助

于 2011-04-06T14:33:17.983 回答
1

如果由于某种原因设置权重不适用于您的情况,请查看http://developer.android.com/reference/android/widget/TextView.html中的 padding、paddingBottom、paddingLeft、paddingRight 和 paddingTop

于 2011-04-06T14:33:20.523 回答
0

您可以手动为“setText”中的字符串添加一个空格,或者如果周围的 ViewGroup 支持它,您可以在 XML ( layout_marginRight) 或通过代码 ( LayoutParams) 中的 TextViews 上设置右边距。

于 2011-04-06T14:38:14.313 回答