如何添加换行符?

时间:2011-06-29 10:17:44

标签: android

如何在android中动态添加换行符?

 TableRow tr5 = new TableRow(this);
                    tr5.setLayoutParams(new LayoutParams(
                            LayoutParams.WRAP_CONTENT,
                            LayoutParams.WRAP_CONTENT));
                    TextView b5 = new TextView(this);
                    b5.setLayoutParams(new LayoutParams(
                            LayoutParams.WRAP_CONTENT,
                            LayoutParams.WRAP_CONTENT));
                    b5.setText("Hello");



                    tr5.addView(b5);

                    tl.addView(tr5,new TableLayout.LayoutParams(
                            LayoutParams.WRAP_CONTENT,
                            LayoutParams.WRAP_CONTENT));

1 个答案:

答案 0 :(得分:0)

您可以在动态生成行后添加此项 这将动态添加休息

View m1 = new View(this);



                       m1.setBackgroundColor(0xFFCDCDCD);



                      m1.setLayoutParams(new LayoutParams(
                                LayoutParams.FILL_PARENT,
                                LayoutParams.WRAP_CONTENT));


                      tl.addView(m1, new TableLayout.LayoutParams(1,1));