2

Please look into the source code below :

public void test_Horizontalscroll() throws Exception {
        solo.sleep(3000);
        Gallery feature= (Gallery) solo.getView(R.id.featured_gallery);
        solo.clickOnView(feature);
        solo.scrollToSide(Solo.LEFT) ;
        solo.sleep(10000); 
}

The issue is that the entire screen is not horizontally scrollable, but only the Top section which is of type Gallery ( android.widget.Gallery)

Please help me.

HitOdessit
  • 7,198
  • 4
  • 36
  • 59
user1664899
  • 327
  • 2
  • 4
  • 15

3 Answers3

1
// Scroll Left // Drag Right

fromX = (screenWidth/2) - (screenWidth/3);

toX = (screenWidth/2) + (screenWidth/3);

fromY = screenHeight/2;

toY = screenHeight/2;

solo.drag(fromX, toX, fromY, toY, 1);

Log.d(TAG,"Scroll Left");

i hope this code will help you.

VISHAL VIRADIA
  • 1,388
  • 1
  • 15
  • 34
  • Thanks but I used it and now there is another issue : Now it tires to scroll but it cannot drag the screen completely and seems as if the screen is so heavy to move .it moves it half and then fails. – user1664899 Nov 21 '12 at 07:44
0

you can use solo.drag() method.

Display d =((WindowManager)activity.getApplication().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();

solo.drag(d.getWidth() / 2 , 0, 10 , 10 , 1);

just change the drag params to your needs.

fgeorgiew
  • 1,194
  • 2
  • 8
  • 25
0

I think the best thing to use is:

solo.scrollViewToSide(solo.getView(R.id.featured_gallery, solo.RIGHT);

You replace the R.id.featured_gallery with the resource id of the view or element (as they're all views anyway) that you're trying to scroll and use either

solo.RIGHT 

or

solo.LEFT 

to scroll the element. Hope it helps.

psionicNinja
  • 111
  • 3