Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Relying on the topic, in which you do, try to write in the constructor of the class <code>LinedEditText</code></p> <pre><code>mPaint = new Paint(); mPaint.setARGB(255, 0, 0, 0); mPaint.setStyle(Paint.Style.STROKE); mPaint.setPathEffect(new DashPathEffect(new float[] {10,10}, 0)); </code></pre> <p>instead of</p> <pre><code>mPaint = new Paint(); mPaint.setStyle(Paint.Style.STROKE); mPaint.setColor(0x800000FF); </code></pre> <p><strong>EDIT:</strong></p> <p>and tell me please again, do you want like this:</p> <p><img src="https://i.stack.imgur.com/Tdc7R.jpg" alt="underline the whole of textView"></p> <p>or this:</p> <p><img src="https://i.stack.imgur.com/pxS45.jpg" alt="underline each line"></p> <p><strong>EDIT:</strong></p> <p>MainActivity:</p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); LayoutParams textViewLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); String text = "Sample Sample Sample Sample Sample Sample Sample Sample Sample Sample"; LinedEditText et = new LinedEditText(this, null, text); et.setText(text); et.setLayoutParams(textViewLayoutParams); et.setKeyListener(null); ll.addView(et); this.setContentView(ll); } </code></pre> <p>LinedEditText:</p> <pre><code>public class LinedEditText extends EditText { private Rect mRect; private Paint mPaint; String text; public LinedEditText(Context context, AttributeSet attrs, String text) { super(context, attrs); this.text = text; mRect = new Rect(); mPaint = new Paint(); mPaint.setARGB(255, 0, 0, 0); mPaint.setStyle(Style.STROKE); mPaint.setPathEffect(new DashPathEffect(new float[] { 10, 10 }, 0)); } @Override protected void onDraw(Canvas canvas) { Rect r = mRect; Paint paint = mPaint; int lineCount = getLineCount(); int size = getLayout().getLineStart(lineCount-1); String str = getText().toString().substring(size); float densityMultiplier = getContext().getResources().getDisplayMetrics().density; float scaledPx = 20 * densityMultiplier; paint.setTextSize(scaledPx); float i = paint.measureText(str); for (int k = 0; k &lt; lineCount-1; k++) { int baseline = getLineBounds(k, r); canvas.drawLine(r.left, baseline + 2, r.right, baseline + 2, paint); } int baseline = getLineBounds(lineCount-1, r); canvas.drawLine(r.left, baseline + 2, i, baseline + 2, paint); super.onDraw(canvas); } } </code></pre>
    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.
 

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