我正在看記事本樣品在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