I have an android alert dialog that I show to user upon first time use. Now the text in this alert dialog is large, so scrolling is necessary.
I would like to make the dialog scroll by itself when the user presses OK button, till he reaches the end of the text.
How to go about this programmatically?
Pseudocode of expected behaviour:
alert.setPositiveButton("Let's Get Started!!",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if(scrolled_till_end)
dismissDialogue();
else
scrollFurther(); // scroll_further to next unviewed part of dialog
}
});
ScrollView#smoothScrollTo()
to scroll it to the bottom.that's it.
Edit #1 in the onClickListener maybe something like:
int textTotalHeight = textView.getHeight();
int pageHeight = scrollView.getHeight();
int scrollY = scrollView.getScrollY();
if(scrollY < textTotalHeight - pageHeight) {// not touch the bottom
scrollView.smoothScrollTo(0, scrollY + pageHeight);// scroll one page height
} else {// touch the bottom, dismiss the dialog
dialog.dismiss();
}