Adding Sliding Tabs using Support Library v7:21 with Toolbar in Android Developer Tools for existing project

后端 未结 4 1057
青春惊慌失措
青春惊慌失措 2020-12-30 08:55

I have already read the information in this link: Use Tab with new ToolBar (AppCompat v7-21) and did a lot of research on the same.

But the problem is the SlidingTab

4条回答
  •  一个人的身影
    2020-12-30 08:58

    I also had the same problem. Since that Android is changing the usage of ActionBar and Tabs again and again it is really hard to know what is the most appropriate implementation of it.

    So I followed the sample that is shown here but I added some additional functionalities. You can see my version and its' usage on this gist.

    What I added are;

    • Enabling giving tabs equal width (if there are two tabs they'll have half width of actionbar)
    • Showing image instead of text or showing both (with your custom view) text and image at tabs

    UPDATE

    There is a new layout called Tab Layout within the support library. You can use it instead.

    Also you can see another response here tells more about it.

提交回复
热议问题