Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>EDIT:</strong><br /> I would try with the XML below (you'd, of course, update the id's etc.). The "magic" in the xml is that it distributes all available width evenly among the <code>TextView</code>'s (and the <code>EditText</code>'s on the second row).</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"&gt; &lt;!-- The first "row" --&gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"&gt; &lt;TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="TextView 01" android:id="@+id/textView01" /&gt; &lt;!-- Here you'd add your other five TextView's accordingly --&gt; &lt;/LinearLayout&gt; &lt;!-- The second "row" --&gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"&gt; &lt;EditText android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="TextView 01" android:id="@+id/editText01" /&gt; &lt;!-- Here you'd add your other five EditText's accordingly --&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>In your Java code you could then access your EditText views like:</p> <pre><code>EditText editText01 = (EditText) findViewById(R.id.editText01); editText01.setText("1"); </code></pre> <p>I have now ignored the fact that you need to create your EditText's programatically. Do you <em>really</em>, <em><strong>really</strong></em> need to create them in Java? (Why?)</p> <p><strong>OLD ANSWER:</strong><br /> If you just want to set the layout margins to your EditText view i quess you could use the <code>setMargins(left, top, right, bottom)</code> function call on the <code>LayoutParams</code> variable.</p> <pre><code>int left = 6; int top = 12; int right = 6; int bottom = 6; TableRow.LayoutParams params = new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.setMargins(left, top, right, bottom); EditText edXY = new EditText(inventory.this); edXY.setLayoutParams(params); </code></pre> <p>If you ultimately wish to distribute all available space evenly among the six EditText views in a table row I would suggest you have a look at the following post: <a href="https://stackoverflow.com/questions/4725024/2-column-tablelayout-with-50-exactly-for-each-column">2-column TableLayout with 50% exactly for each column</a></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