Note that there are some explanatory texts on larger screens.

plurals
  1. POEllipsize not working in this table layout
    text
    copied!<p>I am currently trying to learn Android. Have been reading tutorials and manual for some days now. I am stuck at a layout issue.</p> <p>I'm scrapping the content from a webpage and displaying it to the user. That's the working of my app.</p> <p>My layout is as follows:</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="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:padding="5px"&gt; &lt;TextView android:id="@+id/tvOutput" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /&gt; &lt;ScrollView android:id="@+id/scrollView1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="5dp"&gt; &lt;LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" &gt; &lt;TableLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:stretchColumns="0" android:id="@+id/tblOutput"&gt; &lt;TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;/TableRow&gt; &lt;TableRow android:id="@+id/tableRow2" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;/TableRow&gt; &lt;TableRow android:id="@+id/tableRow3" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;/TableRow&gt; &lt;TableRow android:id="@+id/tableRow4" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;/TableRow&gt; &lt;TableRow android:id="@+id/tableRow5" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;/TableRow&gt; &lt;TableRow android:id="@+id/tableRow6" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;/TableRow&gt; &lt;TableRow android:id="@+id/tableRow7" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;/TableRow&gt; &lt;TableRow android:id="@+id/tableRow8" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;/TableRow&gt; &lt;TableRow android:id="@+id/tableRow9" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;/TableRow&gt; &lt;TableRow android:id="@+id/tableRow10" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;/TableRow&gt; &lt;TableRow android:id="@+id/tableRow11" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;/TableRow&gt; &lt;/TableLayout&gt; &lt;Button android:id="@+id/btnBack" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/lblBack" android:layout_marginTop="10dip"/&gt; &lt;Button android:id="@+id/btnSendSMS" android:layout_width="80dp" android:layout_height="wrap_content" android:text="@string/lblSendSMS" /&gt; &lt;/LinearLayout&gt; &lt;/ScrollView&gt; </code></pre> <p></p> <p>Via code, I'll loop through the TableRows and add two TextViews each. Below is a sample piece of it:</p> <pre><code> for(i=1;i&lt;=11;i++){ TextView tv1 = new TextView(getApplicationContext()); TextView tv2 = new TextView(getApplicationContext()); //get values and store it in strValue1 &amp; strValue2 //.... tv1.setText(strValue1); //a long text tv2.setText(strValue2); //would always be a 3 letter value //tv1.setEllipsize(TruncateAt.MARQUEE); //tv1.setMarqueeRepeatLimit(1); tv1.setSingleLine(true); tv1.setEllipsize(TruncateAt.END); tv1.setGravity(Gravity.LEFT); tr = (TableRow) findViewById( getResources().getIdentifier("tableRow"+i, "id", getPackageName())); tr.addView(tv1); tr.addView(tv2); } </code></pre> <p>The problem is, setEllipsize() for the first TextView on each TableRow is not doing anything. It just shows the text of first TextView (long text overflowing the width) and the TextView2 is not even displayed.</p> <p>When I tried the setEllipsize() and setSingleLine() on an existing TextView (the very first TextView in my layout - you could see from the above XML, which is above the Table Layout), it's working fine.</p> <p>Any ideas where I went wrong ? Or any suggestions ?</p> <p>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