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 9062553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:45:57+00:00 2026-06-16T15:45:57+00:00

I want to create a notepad. I am referring to sample notepad that provided

  • 0

I want to create a notepad. I am referring to sample notepad that provided by android sdk. My problem is I failed to draw multiple lines on editText. I am successfully run the program but there is nothing shows on the editText and even worse I couldn’t input a word onto it. Here is my code. Thank you for helping.

On view, I have double confirm with my class path.So, I don’t think there is any problem with my class path.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView 
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:id="@+id/layouteditbottom"
        android:layout_alignParentBottom="true"
        android:paddingBottom="18dp"
        />  

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:paddingBottom="5dp"
        android:paddingTop="5dp"
        android:layout_above="@+id/layouteditbottom">
        <TextView android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="18sp" 
            android:text="@string/title"
            android:id="@+id/title_text1" />

        <EditText android:id="@+id/title"
            android:layout_toRightOf="@+id/title_text1"             
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:singleLine="true"
            android:imeOptions="actionNext"
            android:textSize="18sp"/>

        <View xmlns:android="http://schemas.android.com/apk/res/android"
            class="com.example.apps2.MainActivity$LineEditText"
            android:id="@+id/body"
            android:layout_below="@+id/title"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:background="@android:color/transparent"
            android:padding="5dp"
            android:scrollbars="vertical"
            android:fadingEdge="vertical"
            android:gravity="top"
            android:textSize="22sp"
            android:capitalize="sentences"/> 
    </RelativeLayout>
</RelativeLayout>

Code below is java.

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);     

    }

     public static class LineEditText extends EditText{
            // we need this constructor for LayoutInflater
            public LineEditText(Context context, AttributeSet attrs) {
                super(context, attrs);
                    mRect = new Rect();
                    mPaint = new Paint();
                    mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
                    mPaint.setColor(Color.BLUE);
            }

            private Rect mRect;
            private Paint mPaint;       

            @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();//for long text with scrolling

                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);
           }

    }   

}
  • 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-16T15:45:59+00:00Added an answer on June 16, 2026 at 3:45 pm

    Thank you for everyone who answered. I solved it by replacing the view from the outermost relativeLayout to the inner relativeLayout. Following code is the answer.

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <TextView 
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:id="@+id/layouteditbottom"
            android:layout_alignParentBottom="true"
            android:paddingBottom="18dp"
            />  
    
        <RelativeLayout
            android:id="@+id/toplayout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="5dp"
            android:paddingTop="5dp"        
            android:layout_alignParentTop="true">       
            <TextView android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="18sp" 
                android:text="@string/title"
                android:id="@+id/title_text1" />                    
            <EditText android:id="@+id/title"
                android:layout_toRightOf="@+id/title_text1"             
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:singleLine="true"
                android:imeOptions="actionNext"
                android:textSize="18sp"/>
            <TextView
                android:id="@+id/notelist_date"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"              
                android:paddingRight="10sp"             
                android:textSize="18sp" />      
        </RelativeLayout>
    
        <view
            xmlns:android="http://schemas.android.com/apk/res/android"
            class="com.example.note1.NoteEdit$LineEditText"
            android:id="@+id/body"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@+id/layouteditbottom"
            android:layout_below="@+id/toplayout"      
            android:background="@android:color/transparent"
            android:capitalize="sentences"
            android:fadingEdge="vertical"
            android:gravity="top"
            android:padding="5dp"
            android:scrollbars="vertical"
            android:textSize="22sp" />
    </RelativeLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So basically I want to create a batch script that can run any notepad
i want create multiple search where statement $where_search is a multiple condition from post
I want create wordpress website into which I want create user management... That means
i want create a custom json data from the mssql 2008 results so that
I want to create a new field (or two) in my table that is
Naming Android mime-types/Uris: The sample notepad application uses: vnd.android.cursor.dir/vnd.google.note vnd.android.cursor.item/vnd.google.note Let's say I want
I'm trying to create a notepad/wordpad clone. I want to save it in .rtf
I'm trying to create a generic, reusable view, that looks like a lined notepad.
I want to create like a notepad in js and php but I want
So I've been modifying the notepad tutorial code: http://developer.android.com/resources/tutorials/notepad/notepad-ex1.html . Basically what I want

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.