android - TextView not ellipsizing in LinearLayout inside TableRow -


i have tried make textviews ellipsize (they located in linearlayout inside tablerow), however, not ellipsize correctly unless manually set maxems (which not want do). note: entire xml (apart tablelayout) generated programmatically.

i have tried fixes: messing (a bit) layout parameters, changing setmaxlines setsingleline, among other fixes still apologise if answer staring me in face!

code generation:

tablelayout tablelayout = (tablelayout) view.findviewbyid(r.id.table);      // add text     (int iter=0;iter<displayjson.summarydata.tasks.length;iter++) {         tablerow tablerow = new tablerow(this);         tablerow.setpadding(16,16,16,16);          linearlayout container = new linearlayout(this);         container.setorientation(linearlayout.vertical);          tablelayout.layoutparams rowparams = new tablelayout.layoutparams(                 tablelayout.layoutparams.match_parent,                 tablelayout.layoutparams.wrap_content);          tablerow.layoutparams layoutlayoutparams = new tablerow.layoutparams(                 linearlayout.layoutparams.match_parent,                 linearlayout.layoutparams.wrap_content);          linearlayout.layoutparams layoutparams = new linearlayout.layoutparams(                 linearlayout.layoutparams.match_parent,                 linearlayout.layoutparams.wrap_content,                 1.0f);          textview titleview = new textview(this);         titleview.settext(displayjson.summarydata.tasks[iter].get("title"));         titleview.setellipsize(textutils.truncateat.end);         titleview.setmaxlines(1);         //titleview.setmaxems(22); not want set (but setting work expected)         titleview.setlayoutparams(layoutparams);          textview classview = new textview(this);         classview.settext(displayjson.summarydata.tasks[iter].get("class"));         classview.setlayoutparams(layoutparams);          container.addview(titleview);         container.addview(classview);         container.setlayoutparams(layoutlayoutparams);          tablerow.addview(container);          setonclick(tablerow, iter); //custom function not affect problem         tablerow.setlayoutparams(rowparams);          tablelayout.addview(tablerow);     }      setcontentview(view); 

tablelayout xml:

<tablelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/table" android:layout_width="match_parent" android:layout_height="match_parent" android:shrinkcolumns="1"></tablelayout> 

i should note before added linearlayout , 'classview' textview, ellipsizing working correctly (may have been different code). also, titleview textview needs ellipsize, classview 1 should not.

any appreciated, , should note none of code has this, , can changed long has same output.

if @ output of layout inspector in android studio, see titleview blowing out width of table row. change layout parameters linear layout give weight follows , see ellipsis appear:

tablerow.layoutparams layoutlayoutparams = new tablerow.layoutparams(         linearlayout.layoutparams.match_parent,         linearlayout.layoutparams.wrap_content,         1.0f); 

i hope helps.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -