[android-developers] Re: Extremely frustrating = TextView in ScrollView - Scroll to bottom?

2009-05-28 Thread skink



On 28 Maj, 01:28, Peter Carpenter
peter.carpen...@skytechnologies.com wrote:
 Hi guys,


 It appears that plenty of people have asked about this in newsgroups,
 but no solution offered.

 textView.setText(s);


try:
tv.setText(s);
sv.post(new Runnable() {
void run() {
sv.scrollTo(0, yPosition);
}
});










--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Extremely frustrating = TextView in ScrollView - Scroll to bottom?

2009-05-28 Thread Peter Carpenter

Oh dear...
I should have tried that first.  It works beautifully!
Thanks very much skink.  I wasn't able to get the Selection.SetSelection
to work even if I posted it later.  There's obviously something I don't
quite understand about how all of this works. - Like why I need to put a
TextView that supports scrolling inside a scrollview to do this
anyway... :S

After experimenting a bit more I was only able to get the following 2
commands to work:

sv.post(new Runnable() {
public void run() {
sv.scrollTo(0, tv.getHeight());
}
});

And 

sv.post(new Runnable() {
public void run() {
sv.fullScroll(ScrollView.FOCUS_DOWN);
}
});

Thanks skink  Raphael

-Original Message-
From: android-developers@googlegroups.com
[mailto:android-develop...@googlegroups.com] On Behalf Of skink
Sent: Thursday, 28 May 2009 6:52 PM
To: Android Developers
Subject: [android-developers] Re: Extremely frustrating = TextView in
ScrollView - Scroll to bottom?




On 28 Maj, 01:28, Peter Carpenter
peter.carpen...@skytechnologies.com wrote:
 Hi guys,


 It appears that plenty of people have asked about this in newsgroups,
 but no solution offered.

 textView.setText(s);


try:
tv.setText(s);
sv.post(new Runnable() {
void run() {
sv.scrollTo(0, yPosition);
}
});













--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Extremely frustrating = TextView in ScrollView - Scroll to bottom?

2009-05-27 Thread Raphael

I often use a TextView withing a ScrollView as a quick log in early
prototype of apps, for debugging.
Typically I just set the selection to the end of the text, which moves
the caret and thus makes sure it's visible:

mLogTextView.append(msg);
mLogTextView.setSelected(true);
Spannable text = (Spannable) mLogTextView.getText();
Selection.setSelection(text, text.length());

R/


On Wed, May 27, 2009 at 7:28 PM, Peter Carpenter
peter.carpen...@skytechnologies.com wrote:
 Hi guys,



 I can’t for the life of me work out how to get a text view to be displayed
 scrolled to the bottom.



 It appears that plenty of people have asked about this in newsgroups, but no
 solution offered.



 textView.setText(s);

 scrollView.fullScroll(ScrollView.FOCUS_UP);



 The above code is called, and whilst the text is updated correctly, the view
 is not scrolled.

 (I’ve tried ScrollView.FOCUS_DOWN) and that doesn’t work either



 Do I need to force the scrollView to measure itself before calling the
 scroll function?  If so what would be the best way to go about doing this
 and then calling the scroll.



 I’ve also tried setting the text as spannable and setting the cursor
 position to the end.



 Cheers,



 Peter.

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---