Vlad Alexeev
Vlad Alexeev

Reputation: 2214

ScrollView - using scrollTo in a Fragment

I've got a scrollview that is on a Fragment that is on a ViewPager and I want to scroll it to some position on start, after pager.setCurrentItem(numberOfPage); where numberOfPage is a remembered last page.

So , if I do scrollTo() in a Fragment onCreateView() - it wouldn't scroll anywhere because it just creates view and not yet inflate it, so it doesn't scroll

I would of scroll it in a onPageSelected(int position) in Activity, but it works only on manually selected ViewPager's fragment and I'm setting it in the beginning as I already mentioned.

So, how can I scroll it right after Inflation?

Upvotes: 0

Views: 2600

Answers (1)

Hassan Jawed
Hassan Jawed

Reputation: 1650

Call scrollTo() method in Fragments onViewCreated()

Upvotes: 3

Related Questions