0

I'm sure you know Google Play, I have tab bar with more than 5 tabs. So it's scrollable (horizontally), but i need to scroll it programatically just for 20dp so that the user will notice the scroll function as soon as he/she sees it.

is there an easy way to do that?

Cœur
  • 37,241
  • 25
  • 195
  • 267

2 Answers2

1

Try this,

TabWidget tw = (TabWidget) findViewById(android.R.id.your_tab_id);
LinearLayout ll = (LinearLayout) tw.getParent();
HorizontalScrollView hs = new HorizontalScrollView(this);
hs.setLayoutParams(new FrameLayout.LayoutParams(
    FrameLayout.LayoutParams.MATCH_PARENT,
    FrameLayout.LayoutParams.WRAP_CONTENT));
ll.addView(hs, 0);
ll.removeView(tw);
hs.addView(tw);
hs.setHorizontalScrollBarEnabled(false);

credits goes to here

Community
  • 1
  • 1
No_Rulz
  • 2,679
  • 1
  • 20
  • 33
0

I think this is exactly what you're looking for: http://developer.android.com/reference/android/widget/ScrollView.html#smoothScrollTo%28int,%20int%29

As you're using a Horizontal scrolling, you have to specify the 'x' axis to move. Just tune it until you think it's ok.

nKn
  • 13,691
  • 9
  • 45
  • 62