Android Question Glow at top, or bottom, of ScrollView window if text is there

TheWind777

Active Member
Licensed User
Longtime User
I have seen Apps which show glowing color on the top if there is text that can be seen by scrolling in that direction, or on the bottom of the scroll window if there is text 'below' the ScrollView (or a glow at top AND bottom if there's text in either direction).

It tends to be transparent, and bulges out a bit so people can see it. Also tapers off so it looks like a light.

Is there some Library that can be added to do that, or is it some setting I don't know about. Or do I have to put a picture, centered, at the top middle or bottom middle that has its alpha setting turned half-way (and what would the code look like to do such a thing?)
 

barx

Well-Known Member
Licensed User
Longtime User
This is the standard behaviour of the scroll view. It is known as over scroll.
 
Upvote 0

TheWind777

Active Member
Licensed User
Longtime User
This is the standard behaviour of the scroll view. It is known as over scroll.

No, not overscroll.

It is to indicate that there IS text in that direction... not that it is the END of text in that direction. Overscroll only shows when you REACH the end.

I want a thing which looks like it's illuminated by an LED at the top of the screen only if there is text available to scroll in the 'up' direction. At the same time I want the same kind of LED indicator at the bottom of the ScrollView which shows that there is text available to scroll in THAT direction.

So, at first, if there's no text in either direction because the text is smaller than the ScrollView, neither indicator are 'lit'.

If he text IS bigger than the ScrollView. at first, there would be no text in the 'Up' direction, so the top LED would be Off. However, there is text in the 'down' direction; so the 'bottom' LED is now on.

Once you scroll to the end of the text, the bottom indicator would turn off because there is no longer any text in the 'down' position; but the top indicator is On because there is text in that direction.

...

I almost have it working. I created two png images with transparent backgrounds and a curved faded purple color. I saved them out as top.png and bottom.png and have positioned them properly using a Layout Script so the top one is centered at the top of the ScrollView, the bottom image is centered at the bottom of the ScrollView.

I have all of them working properly except for the bottom indicator shutting-off when it reaches the end of the text.

I can't figure out how one tells that the ScrollPos position is at the largest ScrollPos Position.

The ScrollPos number doesn't seem to have any relationship at all with the text height, or the EditTextBox.Text.Height. or even the height that was returned from the StringUtils.MeasureMultilineTextHeight() function.

I am doing the following, for example:

B4X:
pnlWB.LoadLayout("lessons")

scvWBLesson.Panel.LoadLayout("edtWBLesson")

EditTextWBLesson.Gravity = Gravity.Top

EditTextWBLesson.Top = 0

EditTextWBLesson.Height = scvWBLesson.Height

scvWBHeight = scvWBLesson.Height

pnlWB.Visible=False

So, I have the ScrollView embedded in the "lessons" Layout.

I have the EditText in a separate Layout and attach it to the ScrollView.

scvWBHeight is memorized so I know how tall the ScrollView used to be before I change it to equal the text height.

I later load the Text (called TheRest) from a .txt file and I call StrUtils to figure-out the Height of the Multiline Text.

scvWBTextHeight = StrUtils.MeasureMultilineTextHeight(EditTextWBLesson, TheRest)



In my ChangeScroll sub:

==========================================
B4X:
Sub scvWBLesson_ScrollChanged(Position AsInt)

IfDoScrollPosThen

IfPGDebugging4ThenLog(" +++ Begin of scvWBLesson_ScrollChanged()")

IfPGDebugging4ThenLog("scvWBLesson_ScrollChanged() - Position = " & Position)

SaveWBScrollPos(Position, WBNumber)



IfDoGlowThen

If Position < 20Then

ImageViewWBTopGlow.Visible = False

Else

ImageViewWBTopGlow.Visible = True

EndIf

IfPGDebugging4ThenLog("scvACIMChapter_ScrollChanged() - scvWBHeight = " & scvWBHeight)

IfPGDebugging4ThenLog("scvACIMChapter_ScrollChanged() - scvWBTextHeight = " & scvWBTextHeight)

EndIf



DoEvents

IfPGDebugging4ThenLog(" --- End of scvWBLesson_ScrollChanged()")

IfPGDebugging4ThenLog(" ")

EndIf

End Sub
=================================================

When I scroll to the end of the text, scvWBHeight = 1260
scvWBTextHeight = 3398

And, the highest ScrollPos that you can reach is 2130

I don't understand the relationship between ScrollPos and, either the text height, or the ScrollView height?

Anybody know the relationship? I need to compute something that becomes TRUE when ScrollPos gets to about 2125 so I can turn off my 'Down' LED indicator.
 
Last edited:
Upvote 0

TheWind777

Active Member
Licensed User
Longtime User
When posting code please use the [code] ... [/code] tags or export and attach your project.

I've been working on my code for three months. It is proprietary and can't be posted (besides, it is gigantic)

Never used code tags before. Huh, that's simple... I just modified the message to show the code sections However, the code is rather irrelevant I am needing to know how one can tell when the largest possible ScrollPosition value has been reached.
 
Last edited:
Upvote 0

TheWind777

Active Member
Licensed User
Longtime User
When posting code please use the [code] ... [/code] tags or export and attach your project.

Didn't know about code tags. There, try that.

But, even forgetting the code. The question is...

How does one know that the largest ScrollPos value has been reached?

I have the height of the ScrollView, the text size and the height of the text as it is returned from the StrUtils.MeasureMultilineTextHeight() function.

How does one compute that the largest ScrollView has been reached using any set of value at all (those I gave, or any other variables I could use)?
 
Upvote 0

TheWind777

Active Member
Licensed User
Longtime User

Ooh.. That looks very useful.

The code, the way I currently have it, sometimes misses turning-off the top or bottom indicator. It 'bobbles' (even if I compare it with the top minus 10, or even the top minus 100, for example).

Works otherwise. If I could get it to be more responsive than that... it would be nice. I'll see what that does and test it out.

Thanks so much. You are very kind.
 
Upvote 0
Top