Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - give space between dynamically created table rows
    text
    copied!<p>I have a Table Layout defined within LinearLayout as follows:</p> <pre><code> &lt;LinearLayout android:layout_width="match_parent" android:layout_height="fill_parent" android:background="#E6E6E6" android:orientation="vertical" &gt; &lt;TableLayout android:id="@+id/fbTableLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp" android:background="@android:color/darker_gray" android:stretchColumns="*" &gt; &lt;/TableLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>I am adding dynamic rows to the TableLayout as follows:</p> <pre><code>fbTableLayout = (TableLayout) findViewById(R.id.fbTableLayout); for (int i = 0; i &lt; 4; i++) { fbTableRow = new TableRow(this); fbTableRow.setBackgroundColor(Color.WHITE); LayoutParams layoutParams = new LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); int leftMargin=10; int topMargin=2; int rightMargin=10; int bottomMargin=2; layoutParams.setMargins(leftMargin, topMargin, rightMargin, bottomMargin); fbTableRow.setLayoutParams(layoutParams); ImageView iv = new ImageView(this); iv.setBackgroundDrawable(getResources().getDrawable( R.drawable.ic_launcher)); iv.setLayoutParams(new LayoutParams(0, LayoutParams.WRAP_CONTENT, 0.25f)); TextView tv = new TextView(this); tv.setText("Album "+ i); tv.setLayoutParams(new LayoutParams(0, LayoutParams.WRAP_CONTENT, 0.75f)); fbTableRow.addView(iv); fbTableRow.addView(tv); fbTableLayout.addView(fbTableRow, new TableLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); } </code></pre> <p>But I am not able to generate spaces between the rows generated. The layout is as shown in the figure attached.</p> <p><img src="https://i.stack.imgur.com/rhUOH.png" alt="enter image description here"></p> <p>I have gone through a number of solutions given in stackoverflow to resolve this issue but none of them are working for me. Not sure what I am missing. Any help would be greatly appreciated. Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload