Android - 类似 Google Play 的标签 [英] Android - Google Play like tabs

查看:16
本文介绍了Android - 类似 Google Play 的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google 刚刚为其在 Google Play 中的标签实现了新外观.

Google has just implemented a new look to their tabs in Google Play.

我知道这可以通过 ViewPagerIndicator 完成,但我不想在我的应用程序中使用另一个库并将应用程序的大小增加另一个 MB 左右.

I know this can be done with ViewPagerIndicator, yet I wouldn't like to use another library in my application and bump the app's size by another MB or so.

我目前正在使用 android.support.v4.view.PagerTabStrip(就像在旧的 Google Play 中一样),我想知道新外观是否也可以使用 android 支持库来实现.

I am currently using the android.support.v4.view.PagerTabStrip (like in the old Google Play), and I'm wondering if the new look can also be implemented using the android support library.

提前致谢.

推荐答案

设计支持库(当前方法).

设计支持库包括 TabLayout 小部件,它允许您实现 Google Play-lie 选项卡:

Design Support Library (current method).

The Design Support Library includes the TabLayout widget which allows you to implement a Google Play-lie tabs:

<android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

然后初始化它:

TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);

有关完整示例,请参阅 Cheesesquare 应用程序

For a full example see the Cheesesquare app

这是一个即用型库,您可以在 Github 上找到.

This is a ready-to-use library that you can find on Github.

这篇关于Android - 类似 Google Play 的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆