I
I
igrishaev2012-10-23 11:44:08
Android
igrishaev, 2012-10-23 11:44:08

Smooth tab switching?

Hello. I'm learning Android and I'm facing the following problem.
There is an activity in which there are 5-6 tabs. At the top are the tab titles in a horizontal scroll (because they don't all fit on the screen), below is the contents of the current tab. I want to:
1) be able to smoothly switch the screen with my finger, seeing the next screen before releasing my finger;
2) the title of the selected tab smoothly moved to the center.
As I have already seen, there is no ready-made widget that meets all these requirements.
So far, I have implemented it this way: I hung a handler on the activity, which determines that there was a swipe (dash with a finger across the screen), and, depending on the direction, makes the previous or next tab active. The downside is that the transition is not animated, but instantaneous (at least so), and the tab title does not move to the center (it may remain off the screen).
The question is how to implement it correctly?
The application is being developed for version 2.1, I have seen the above in many applications. I would be very grateful for help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
serso, 2012-10-23
@igrishaev

If I understood correctly, then you just need to use ViewPager. Here is a good implementation for example:
github.com/JakeWharton/Android-ViewPagerIndicator

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question