Radwa Radwa - 4 months ago 8x
Android Question

Android Scroll ScrollView automatically in onCreate method

I have some kinde of calendar and I use ScrollView to scroll to days
I want it on create it will be scroll able to today date
here is the cod I use:

scrollV.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() {
scr.post(new Runnable() {
public void run() {
scrollV.scrollTo(0,3); }

3 is just for test I'll change it later; thanks in advance.


I solved it here is the answer for any one need it : Just put a timer in OnCreate method or in onCreateView if it is a fragment

new java.util.Timer().schedule(
                new java.util.TimerTask() {
                    public void run() {

day is the variable you want to the list to scroll to it's day of month for me , list is the list view