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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:17:26+00:00 2026-05-22T18:17:26+00:00

As default, an Android EditText will break a line if the line is longer

  • 0

As default, an Android EditText will break a line if the line is longer than the view, like this:

Thisisalineanditisveryverylongs (end of view)
othisisanotherline

or if the line contains a punctuation character, like this:

Thisisalineanditsnotsolong;     (several characters from the end of view)
butthisisanotherline

As a requirement of my work, the text has to break a line only if the line is longer than the view, like this:

Thisisalineanditsnotsolong;andt (end of view)
hisisanotherline

There must be a way to achieve this, am I right? So far I haven’t found anyway to do this.

  • 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-05-22T18:17:27+00:00Added an answer on May 22, 2026 at 6:17 pm

    The way TextView (and EditText) breaks the text is through private function calls to BoringLayout internally. So, the best way would be to sublcass EditText and rewrite these functions. But it will not be a trivial task.

    So, in the TextView class there are creations of different classes for text style. The one we look is DynamicLayout. In this class we reach to a reference of the class StaticLayout (in a variable called reflowed). In the constructor of this class you will find the text wrap algorithm:

    /*
    * From the Unicode Line Breaking Algorithm:
    * (at least approximately)
    *  
    * .,:; are class IS: breakpoints
    *      except when adjacent to digits
    * /    is class SY: a breakpoint
    *      except when followed by a digit.
    * -    is class HY: a breakpoint
    *      except when followed by a digit.
    *
    * Ideographs are class ID: breakpoints when adjacent,
    * except for NS (non-starters), which can be broken
    * after but not before.
    */
    
    if (c == ' ' || c == '\t' ||
    ((c == '.'  || c == ',' || c == ':' || c == ';') &&
    (j - 1 < here || !Character.isDigit(chs[j - 1 - start])) &&
    (j + 1 >= next || !Character.isDigit(chs[j + 1 - start]))) ||
    ((c == '/' || c == '-') &&
    (j + 1 >= next || !Character.isDigit(chs[j + 1 - start]))) ||
    (c >= FIRST_CJK && isIdeographic(c, true) &&
    j + 1 < next && isIdeographic(chs[j + 1 - start], false))) {
    okwidth = w;
    ok = j + 1;
    

    Here’s where all the wrapping goes. So you will need to subclass take care for StaticLayout, DynamicLayout, TextView and finally EditText which – I am sure – will be a nightmare 🙁 I am not even sure how all the flow goes. If you want – take a look at TextView first and check for getLinesCount calls – this will be the starting point.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to make android EditText smaller than default in height? If I change the
By default my EditText has next view: <EditText android:layout_height=wrap_content android:paddingLeft=10dip android:layout_width=wrap_content android:gravity=center_vertical android:inputType=textShortMessage android:id=@+id/search_string
I'm defining an edit text like so... <EditText android:id=@+id/user android:layout_width=200px android:layout_height=wrap_content android:text=Username android:textSize=18sp android:gravity=center
The default rails XML builder escapes all HTML, so something like: atom_feed do |feed|
my question is kinda related to this question: Numeric Soft Keyboard on Android BUT,
By default android checkbox shows text at right side and checkbox at left I
i want to edit the EditTextPreference in android Honeycomb. by default the EditTextPreference shows
default is 49 how to edit to higher?
The default shell in Mac OS X is bash , which I'm generally happy
By default each row of a Gridview maps to each row in a datatable

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.