Android Question [Solved] EditText Wrapping issue

Roger Daley

Well-Known Member
Licensed User
Longtime User
High All

In an existing project I have moved a lot of views on to panels for ease of management. On one panel one of the views is an EditText created in the manifest to gain a decent cursor.
This EditText is only high enough to show one line. This has worked well when in the Activity but there is a problem when added to the Panel.
In the original as the user moves the cursor to the left, text scrolls to the right and out of sight, all looks good.
When the EditText is on the Panel, the text wraps forcing the top of the visible text to be cut off. Nothing of the second line is visible.

I have tried EditText.singleline = True/False and EditText.wrap = True/False in all combinations and nothing seems to change.

Below the two blocks of code and the code from the Manifest.

Activity version:
    Private xcursor As XmlLayoutBuilder
    xcursor.LoadXmlLayout(Activity, "layout1")
    Idisplay = xcursor.GetView("edittext1")
    Idisplay.RemoveView
    Activity.AddView(Idisplay, Rdisplay.Left, Rdisplay.Top + Rdisplay.Height, dmiddle.Width, Rdisplay.Height)
    Idisplay.Left = Rdisplay.Left
    Idisplay.Top = Rdisplay.Top + Rdisplay.Height
    Idisplay.BringToFront


Panel version:
    Private xcursor As XmlLayoutBuilder
    xcursor.LoadXmlLayout(Activity, "layout1")
    Idisplay = xcursor.GetView("edittext1")
    Idisplay.RemoveView
    PnlBASE.AddView(Idisplay, Rdisplay.Left, Rdisplay.Top + Rdisplay.Height, IDWidth, Rdisplay.Height)
    Idisplay.Left = Rdisplay.Left
    Idisplay.Top = Rdisplay.Top + Rdisplay.Height
    'Idisplay.SingleLine = True
    'Idisplay.Wrap = False


Manifest:
'Used to recreate IDisplay with decent cursor
 CreateResource(layout, layout1.xml,
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:paddingLeft="16dp"
  android:paddingRight="16dp"
  android:orientation="vertical" >


   <EditText android:tag="EditText1"  android:id="@+id/edittext1"
  android:layout_width="match_parent" android:layout_height="wrap_content"
        android:textCursorDrawable="@drawable/my_custom_cursor_drawable"
     />
</LinearLayout>
)


It is a small but annoying issue so any help is appreciated.

Regards Roger
 

Roger Daley

Well-Known Member
Licensed User
Longtime User
Erel Thanks for the reply,

EditText.height = 103 in both cases. The Panel is 100%x by 100%y.

Something is making a change and the move from Activity to Panel is about it. Another mystery, I will keep looking.
Perhaps the question really should be, how to stop the text from going to a second line but just scroll off the display.

I will keep thinking.

Regards Roger
 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
A bit of feedback.
As per Erels suggestion to text an Edittext created with the designer. Same problem exists.
I made a small project to demonstrate the problem, of course there was no problem.

From the two points above the obvious conclusion is that I did something wrong somewhere else at the same time I introduced the panel.
Panel and XmlLayoutBuilder innocent.

Regards Roger

EDIT: Found an Erroneous "Idisplay.Wrap = True" where there should be none. Possibly a copy paste error.
 
Last edited:
Upvote 0
Top