Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8241283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:47:12+00:00 2026-06-07T20:47:12+00:00

I want to make a note editor. It will have an EditText with lines.

  • 0

I want to make a note editor. It will have an EditText with lines. Here is my code:

LinedEditText.java

public class LinedEditText extends EditText {


    private Rect mRect;
    private Paint mPaint;

    public LinedEditText(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
        mRect = new Rect();
        mPaint = new Paint();
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        mPaint.setColor(Color.BLUE); //SET YOUR OWN COLOR HERE

    }
    @Override
    protected void onDraw(Canvas canvas) {
        //int count = getLineCount();

        int height = getHeight();
        int line_height = getLineHeight();

        int count = height / line_height;

        if (getLineCount() > count)
            count = getLineCount();

        Rect r = mRect;
        Paint paint = mPaint;

        int baseline = getLineBounds(0, r);//first line
        for (int i = 0; i < count; i++) {

            canvas.drawLine(r.left, baseline + 1, r.right, baseline + 1, paint);
            baseline += getLineHeight();//next line
        }

        super.onDraw(canvas);
    }

TextEditorActivity.java

    public class TextEditorActivity extends Activity {

    private LinedEditText text;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        this.text=new LinedEditText(getApplicationContext());
        this.setContentView(text);
    }

}

And result:

result http://bekirmavus.com/k-resimler/image/android/device-2012-07-17-222950.png

What mistake am i making?

Thanks…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T20:47:13+00:00Added an answer on June 7, 2026 at 8:47 pm

    The line are being drawn from the position of the cursor on down. Simply move the cursor’s default position from vertically centered, to the top-left, with Gravity:

    text.setGravity(Gravity.NO_GRAVITY);
    

    Or set it by default for all LinedEditTexts:

    public LinedEditTexts(Context context) {
        super(context);
        setGravity(Gravity.NO_GRAVITY); // or Gravity.TOP | Gravity.LEFT
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have style sheet with a class name changebackgroundcolor i want make change in
I have a EF4.1 class X and I want to make copy of that
I have link for example domain.com/de/controler/action?param=value and I want make actionlink to keep same
I have uploaded a app in production mode to linode. I want make changes
I have a note editor control in my Windows Forms application: alt text http://img82.imageshack.us/img82/2033/tabtohiddencontrol.png
So I want to make a query to add to the current value. note
I want to make a WPF TextBox have a DarkBlue border and thickness equal
I want to make a program that detects the note that is being played
I want to make a plugin, that I will use for some jQuery AJAX
I want to make my pc both server and client. This is my code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.