I am using the SlidingTabLayout.java and SlidingTabStrip.java classes to implement a tab navigation inside my app like described here.

Everything works fine and I really love this two classes. But I would like to center the selected tab (whether navigated through slide or click on the tab) to be in the middle of tab navigation. Right now it is always on the left side (except when you reach the end of the tab navigation than it is right). Also when you click on a tab the navigation scrolls back to the current tab and scrolls then to the tab you just selected. Is there anyway to stop this scrolling and just to center the clicked tab?

Using the method

slidingTabLayout.setDistributeEvenly(true);

does not do the trick.

I tried to read through the code and find a good starting point but I did not succeed. Does anyone know how to achieve that? Any good advice is highly appreciated.


我认为如果您需要滚动查看选项卡,选项卡会自动居中(即有很多选项卡不滚动就不适合)。

不幸的是,事实并非如此,这就是我问的原因。:)