scrollview automatically scroll to the bottom

raaiman

Member
Licensed User
Longtime User
Hi All,

i am using scrollview to do chat screen,the effect what i want is when i add a new message to the scrollview,it will automatically scroll to the bottom of the screen,but now it can not.
is there anyway to fullfill it?
thanks.
 

raaiman

Member
Licensed User
Longtime User
Hi Erel,
It takes effect when i am in the scrollview list screen and add message one by one.but on the situation i go to the scrollview list from another activity it just stay on the top event i have added sv.ScrollPosition = sv.Panel.Height.
 
Upvote 0

kkolle

Member
Licensed User
Longtime User
Hallo Erel

I try to do this but it dos not work

B4X:
'Save ScrollView Positon

saveScrollPos = myScrollView.ScrollPosition

Now i open other Activity do something an go back.

in resume i fill the list set position back.

B4X:
 myScrollView.ScrollPosition = saveScrollPos

But nothing happen
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Try this code:
B4X:
Private Sub ScrollTo(sv As ScrollView, pos As Int)
   'sv.ScrollTo smoothly scrolls to the position. In this case we want to immediately change the scroll position
   'so we use Reflection to call the native scrollTo method.
   Dim r As Reflector
   r.Target = sv
   r.RunMethod3("scrollTo", 0, "java.lang.int", pos, "java.lang.int")
End Sub
 
Upvote 0

kkolle

Member
Licensed User
Longtime User
Hallo Erel,

thank you for answers. I have solved my problem. My failure was to Dim the scrallview in my funktion.
 
Upvote 0

adalexander

Member
Licensed User
Longtime User
Erel Hello, similar problem with scrollview vertical, I slide text when I turn the phone horizontally the texts related to the photos that are cut and the screen does not scroll at the bottom, how can I do and how you put the scrollview, ie I tried to put scroll but I put it to the whole area of the phone is white but then where am I wrong? thanks for your help in advance.
 
Upvote 0

adalexander

Member
Licensed User
Longtime User
I'm not sure that I completely understand the problem. Can you post the relevant code?
Ti serve il codice della pagina principale dove ho impostato i valori? nn ho messo ancora la scrollview perchè non so come funzioni, non ci capisco niente! grazie.
 
Upvote 0

adalexander

Member
Licensed User
Longtime User
I'm not sure that I completely understand the problem. Can you post the relevant code?
B4X:
Dim Auto1 As AutoCompleteEditText
    Dim ImageView1 As ImageView
    Dim Button1 As Button
    Dim Button2 As Button
    Dim Button3 As Button
    Dim Button4 As Button
    Dim Label1 As Label
    Dim Label2 As Label
    Dim Label3 As Label
    Dim Label4 As Label
    Dim timer1 As Timer
    Dim Img2 As ImageView
   
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
Dim Answ As Int
Dim txt As String
Select KeyCode
Case KeyCodes.KEYCODE_BACK
Answ = Msgbox2("Confermare uscita","ATTENZIONE","Si", "", "No", Null)
If Answ = DialogResponse.NEGATIVE Then
Return True
Else
Activity.Finish
Return False
End If
End Select
End Sub
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("home")
    Auto1.Initialize("Auto1")
    Activity.AddView(Auto1,10dip,10dip,300dip,70dip)
    Dim nomi () As String
    nomi = Array As String ("terme","grand","italia","polo","president","branca","maria","albergo","hotel","stelle","congressi")
    Auto1.SetItems(nomi)
    timer1.Initialize("timer1",5000)
    timer1.Enabled=True
    Img2.Visible=True
    Img2.BringToFront

End Sub
Sub    timer1_tick
    Img2.Visible=False
    timer1.Enabled=False
End Sub
Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub



Sub Button4_Click
    Msgbox("3735254716","info")
End Sub
Sub Button3_Click
    Msgbox("[email protected]","info")
End Sub
Sub Button2_Click
    StartActivity(estero)
End Sub
Sub Button1_Click
    StartActivity(italia)
End Sub

You needed the code of the main page? this is, at least I hope to resolve this problem are increasing because now I can not even create the apk file, then I saw that you sent a new release 3:00 I have to install and overwrite it? give me some help because I do not understand anything, or else are forced to abandon B4A, not for me, thank you.
 
Upvote 0
Top