Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <ol> <li>How can I make the header row height be more like the rows?</li> </ol> </blockquote> <p>Using the default <code>Button</code> there isn't much to do. The <code>Button</code> uses a nine-patch image that has some space between the button's text and the borders that you see. You could use a smaller font but that you'll probably look ugly. Another thing to try is using your own background for the Button and get rid of the default extra space(of the default nine-patch image) so the final height is near the height of the text from the <code>TextView</code>s. Or try to enforce a standard height for all rows using a fixed value.</p> <blockquote> <ol> <li>How can I make the button occupy the full width of the row?</li> </ol> </blockquote> <p>I think that you have more then one <code>TextView</code> in <code>MessageRow</code> so when you add the <code>Button</code> it moves to the first column(corresponding to the first <code>TextView</code>). If this is the case, make your <code>Button</code> <em>span</em> across the number of columns representing the number of <code>TextViews</code> in <code>MessageRow</code>:</p> <pre><code>TableRow.LayoutParams params = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT); params.span = 3; // if you have 3 `TextView` in the MessageRow Button bt = new Button(getContext()); bt.setText("Column1"); mHeader.addView(bt, params); </code></pre> <p>If this is not the case add more details.</p> <blockquote> <ol> <li>How can I make the row fill the screen width? (MATCH_PARENT does not do it)</li> </ol> </blockquote> <p>As I said on one of your previous questions, I don't know why that happens(but I gave you some solutions there to overcome this issue). Also:</p> <ol> <li><p><code>mHeader</code> and the other <code>MessageRow</code> are children of a <code>Tablelayout</code> and the correct <code>LayoutParams</code> to use on them is the <code>LayoutParams</code> of the parent: <code>TableLayout.LayoutParams</code> and <strong>not</strong> <code>TableRow.LayoutParams</code>.</p></li> <li><p>You add some <code>TextView</code> in the <code>MessageRow</code>(from what I seen in your previous questions), add those child views with <code>TableRow.LayoutParams</code> to <code>MessageRow</code>.</p></li> <li><p>You use only <code>WRAP_CONTENT</code> for your <code>LayoutParams</code> everywhere in your code, you might want to set the width(the first parameter in the constructor) to <code>FILL_PARENT</code>/<code>MATCH_PARENT</code></p></li> </ol> <blockquote> <ol> <li>How can I draw a thin line between the table rows?</li> </ol> </blockquote> <p>You could use a simple <code>View</code> that will act as a separator:</p> <pre><code>for(int i = 0; i &lt; 100; i++) { MessageRow mr = new MessageRow(getContext()); // stuff to set the TexView text and color mr.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.WRAP_CONTENT)); this.addView(mr); View separator = new View(getContext()); separator.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT, 3))); separator.setBackgroundColor(Color.RED); this.addView(separator); } </code></pre> <p>Because you have 100 rows you could try to set a drawable with a separator line as the background for the<code>TableRow</code>(<code>header</code> and <code>MessageRow</code>) instead of the above method that adds another 100 Views to the layout.</p> <p><strong>Extra Note:</strong></p> <p>You have a lot of views to add to a single activity layout, you are talking about 100 rows, and if your <code>MessageRow</code> is more complex than a simple <code>TextView</code>(and I think it is) you could get in some performances problems. I suggest you take a look at the wonderful <code>ListView</code> widget.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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