我正在看记事本样品在Android SDK在这里看到:http://developer.android.com/resources/samples/NotePad/src/com/example/android/notepad/NoteEditor.html在edittext中绘制多行记事本
事情是只汲取当前行光标在如http://cdn2.staztic.com/screenshots/simple-notepad-app-al-1.jpg
但我想显示的行填满屏幕,例如http://www.itismyworld.info/wp-content/uploads/2010/03/AK-notebook.png
任何建议将是伟大的。代码的相关位似乎在这里:
protected void onDraw(Canvas canvas) {
// Gets the number of lines of text in the View.
int count = getLineCount();
// Gets the global Rect and Paint objects
Rect r = mRect;
Paint paint = mPaint;
/*
* Draws one line in the rectangle for every line of text in the EditText
*/
for (int i = 0; i < count; i++) {
// Gets the baseline coordinates for the current line of text
int baseline = getLineBounds(i, r);
/*
* Draws a line in the background from the left of the rectangle to the right,
* at a vertical position one dip below the baseline, using the "paint" object
* for details.
*/
canvas.drawLine(r.left, baseline + 1, r.right, baseline + 1, paint);
}
// Finishes up by calling the parent method
super.onDraw(canvas);
}
+1很好的解释.... – 2011-06-09 05:59:57