android - EditText not increasing width when adding BulletSpan -


when adding bulletspan edittext, size of edittext not increased leading space added bullet. leads wrapping or scrolling of text out of sight.

sofar have not been able force edittext remeasure width correctly.

unfortunately have not enough reputation illustrate situation. let me try describe situation.

  1. when adding bulletspan underlying editable of edittext, resulting larger paragraph scrolls behind right edge.

    |0123456789|  -> | • 0123456|789   

    the last characters scrolled behind right edge.

  2. when altered editable assigned edittext, width of field remains same , wider text wraps.

    |0123456789| -> | • 0123456|                 |   789    | 

    in both cases edittext not compensate width leading space.

  3. adding characters @ end of paragraph

    | • 0123456789xxx| |   xxx          | 

    when adding characters edittext, size of field increases expected, not take added space of bullet , margin account , keeps wrapping.

several questions on bulletspans have been asked, not before on weird behaviour. 2 days, i've tried many layout setting in xml , many options in code no avail unfortunately.

does have suggestion?

code: mainactivity.java

        mtoggle.setoncheckedchangelistener(new compoundbutton.oncheckedchangelistener() {         @override         public void oncheckedchanged(compoundbutton compoundbutton, boolean showbullet) {             final editable editable = medittext1.gettext();              if (showbullet) {                 // add bullet                 editable.setspan(new bulletspan(50), 0, editable.length(), spannable.span_paragraph);             } else {                 // remove bullet                 bulletspan[] spans = editable.getspans(0, editable.length(), bulletspan.class);                 if (spans.length > 0) {                     editable.removespan(spans[0]);                 }             }             // see happens when assigning editable other textview             medittext2.settext(editable);         }     }); 

layout: activity_main.xml (partly)

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/relative_layout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingleft="10dp" android:paddingright="10dp">   <!-- togglebutton , textview removed -->  <edittext     android:id="@+id/edittext"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_below="@+id/textview"     android:inputtype="textmultiline"     android:text="0123456789" /> 

try override bulletspan methods , change implementation :

public class mybulletspan extends bulletspan {      @override     public int getleadingmargin(boolean first) {         return super.getleadingmargin(first);     }      @override     public void drawleadingmargin(canvas c, paint p, int x, int dir, int top, int baseline, int bottom, charsequence text, int start, int end, boolean first, layout l) {         super.drawleadingmargin(c, p, x, dir, top, baseline, bottom, text, start, end, first, l);     } } 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -