?
Imagine that you have a TextView or a similar element (in your case, your html # paragraph_1), then you can get the top position of this element:
TextView yourTextView = (TextView) findViewById(R.id.tv_your_text_view);
int position = yourTextView.getTop();
After that, you can go to your position (you can put this piece of code in your onClick () method or similar to go to this position when you click on the link or button):
ScrollView sc = (ScrollView) findViewById(R.id.scroll_view);
sc.post(new Runnable() {
public void run() {
sc.scrollTo(0, position);
}
});
Note. I was expecting to yourTextViewbe in a ScrollView layout.
Hope this helps you get started.
source
share