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

  • SEARCH
  • Home
  • 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 7993383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:50:14+00:00 2026-06-04T13:50:14+00:00

I have asked a question previously titled Android: Ruled/horizonal lines in TextView at Android:

  • 0

I have asked a question previously titled “Android: Ruled/horizonal lines in TextView” at Android: Ruled/horizonal lines in Textview . But I haven’t got required answer. So I’m planing to do this by drawing line on TextView by java.Is there any way to draw Line inside TextView? or if I get end of line from java code then I’ll be able to add textview for each line. Any help will be highly appreciated.

  • 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-04T13:50:15+00:00Added an answer on June 4, 2026 at 1:50 pm

    I’m using the technique of drawing lines between each line of text in EditText and then I will make the EditText non-editable by setting setKeyListener(null) to the custom EditText object so that, the EditText acts like a TextView 🙂


    A custom EditText that draws lines between each line of text that is displayed:

    public class LinedEditText extends EditText {
        private Rect mRect;
        private Paint mPaint;
    
        // we need this constructor for LayoutInflater
        public LinedEditText(Context context, AttributeSet attrs) {
            super(context, attrs);
    
            mRect = new Rect();
            mPaint = new Paint();
            mPaint.setStyle(Paint.Style.STROKE);
            mPaint.setColor(0x800000FF);
        }
    
        @Override
        protected void onDraw(Canvas canvas) {
            int count = getLineCount();
            Rect r = mRect;
            Paint paint = mPaint;
    
            for (int i = 0; i < count; i++) {
                int baseline = getLineBounds(i, r);
    
                canvas.drawLine(r.left, baseline + 1, r.right, baseline + 1, paint);
            }
    
            super.onDraw(canvas);
        }
    } 
    

    Now use object of LinedEditText class where you need your TextView and make it non-editable.

    An Example:

    public class HorizontalLine extends Activity{
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {   
            super.onCreate(savedInstanceState);
            setTitle("Android: Ruled/horizonal lines in Textview");
    
            LinearLayout ll = new LinearLayout(this);
            ll.setOrientation(LinearLayout.VERTICAL);
            LayoutParams textViewLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    
            LinedEditText et = new LinedEditText(this, null);
            et.setText("The name of our country is Bangladesh. I am proud of my country :)");
            et.setLayoutParams(textViewLayoutParams);
            et.setKeyListener(null);
    
            ll.addView(et);
            this.setContentView(ll);
    
        }
    
    }
    

    et.setKeyListener(null) makes the EditText non-editable so, it acts like a TextView.


    The Output:

    enter image description here

    Issue with cursor:

    If you use et.setKeyListener(null) only then it is just not listening to keys but
    user can see a cursor on the EditText. If you don’t want this cursor just disable the EditText by adding this line:

     et.setEnabled(false);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have previously asked a question on AS3 and timing for games but got
I have asked a similar question previously but it was never resolved so here
I have asked a similar question previously, but posting a new one as I
I previously asked the question and got answer to Best approach to write query
Ok, I have previously asked a similar question to this but it was voted
I have seen this question asked previously but can not find a clear explanation
I have previously asked two questions Question 1 and Question 2 but there is
I have previously asked this question and since I already accepted an answer, I
I have asked a similar question previously, but 1. no one answered and 2.
I have asked a question similar to this in the past but this is

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.