Flingable edittext (inside scrollview?)

JesseW

Active Member
Licensed User
Longtime User
Is it currently possible to have a full screen edit text that flings nicely, not like the jerky scrolling of the default edittext view, but more like a nice text editor, like TextPad? It should scroll like a scrollview, not an edittext box, and should also scroll right to the end of the longest line. My clumsy attempt doesn't work very well...

B4X:
Sub Globals
   Dim sv As ScrollView
   Dim ed As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
   sv.Initialize(1000)
   activity.AddView(sv, 0, 0, 100%x, 100%y)
   sv.Panel.Color = Colors.White
   ed.Initialize("ed")
   sv.Panel.AddView(ed, 0, 0, 100%x, 100%y)
   ed.Color = Colors.White
   ed.SelectionStart = 0
End Sub

I'm sure I'm not doing something right... When I paste a long bit of text into it, it doesn't scroll right, and looking through the methods list doesn't give me any ideas...

I looked for an edittext tutorial, or another post that might answer this, but found no answers. Also I noticed that when the soft keyboard popped up, it didn't push the bottom of the scrollview up. I'm missing something, I know I am.

Any help appreciated. Thanks... :)
 
Last edited:

agraham

Expert
Licensed User
Longtime User
Look at the editor in my BasicIDE posting. It uses my Reflection library to change some EditText properties to allow horizontal scrolling.

The appearance of the keyboard doesn't seem to push up the bottom of the EditText unless the EditText is some minimum vertical size. You can see this if you turn the BasicIDE editor to landscape.

As for flinging - I don't know, but I'm not really interested in all this graphics and presentation stuff, it's just a means to an end for me.
 
Upvote 0

JesseW

Active Member
Licensed User
Longtime User
Andrew, I noticed the right scrolling in your IDE earlier. I will take a look.

An edittext stretched all the way out to fit all the text in the window, placed on a scrollview's panel, makes it scroll like a scrollview. Nice and smooth, and flingable, like it has some weight to it and keeps going with some momentum after you take your finger off the screen. I like this, even as a user or programmer, because it's MUCH easier to navigate vs a standard edittext where you have to manually scroll all the way up and down. That's a lot of fingering up and down inside a standard edittext if you have a large file! As a matter of fact, this thread was started because once I figure it out, I plan to replace the edittext in your BasicIDE to make it more usable, for me anyway, because I plan to use it a lot.

I'm wondering if the scrollview needs to use java's FILL_PARENT for the height parameter, so that it will auto-scale when the usable area decreases because the keyboard pushes itself up, but I find no mention of FILL_PARENT anywhere on this site. Another concern is the scrollview's panel probably needs to autosize to the height of the edittext box, which itself needs to autosize itself to accommodate all the text within the viewable window, so none of the text is hidden. >whew<

Does this make sense? I kow what needs to be done, I just don't know the semantic's yet to make it happen. :sign0144:
 
Last edited:
Upvote 0

JesseW

Active Member
Licensed User
Longtime User
I've since found that setting the Height to -1 is the const value for FILL_PARENT, which works good for the scrollview but not its panel, and it seems to work, and -2 is WRAP_CONTENT, which works very well for the edittext but not the scrollview panel.

I think all I need now is a way to make scroll views panel conform heightwise to accommodate the height of the expanded edittext or a way for edittext to report its true height when its height param is set to WRAP_CONTENT. That and the keyboard popup thingie...
 
Upvote 0
Top