Android 5.0 Material 风格的标签页

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26442941/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 11:27:48  来源:igfitidea点击:

Android 5.0 Material-styled tabs

androidandroid-tabsmaterial-design

提问by Nathan Walters

Does the Android 5.0 framework have Material-styled tabs? I know in the dev preview, they were still Holo-styled. I was wondering if 5.0 has been updated with material-style tabs; I currently use PagerSlidingTabStripfor my tabs, but that has not been updated with Material design yet.

Android 5.0 框架是否具有 Material 样式的选项卡?我知道在开发预览中,它们仍然是 Holo 风格的。我想知道 5.0 是否更新了材质样式的选项卡;我目前将PagerSlidingTabStrip用于我的标签,但尚未使用 Material design 进行更新。

More specifically, does the support library include an implementation of material tabs? The Play Store running on 4.x has those tabs, but I'm not sure if that's a custom implementation by Google or not.

更具体地说,支持库是否包括材料选项卡的实现?在 4.x 上运行的 Play 商店有这些选项卡,但我不确定这是否是 Google 的自定义实现。

回答by Jared Burrows

Updated (10/19/2015):

更新(10/19/2015):

This is now provided by the Android Design Support Library:

这现在由 Android 设计支持库提供:

compile "com.android.support:design:23.1.0"

compile "com.android.support:design:23.1.0"

Chris Banes example:

克里斯·班恩斯的例子:

https://github.com/chrisbanes/cheesesquare

https://github.com/chrisbanes/cheesesquare

Android Developer Blog:

Android 开发者博客:

http://android-developers.blogspot.com/2015/05/android-design-support-library.html

http://android-developers.blogspot.com/2015/05/android-design-support-library.html

Android Docs:

安卓文档:

http://developer.android.com/reference/android/support/design/widget/TabLayout.html?utm_campaign=io15&utm_source=dac&utm_medium=blog

http://developer.android.com/reference/android/support/design/widget/TabLayout.html?utm_campaign=io15&utm_source=dac&utm_medium=blog

Support Library:

支持库:

https://developer.android.com/tools/support-library/features.html#design

https://developer.android.com/tools/support-library/features.html#design

Original Answer:

原答案:

Look at the latest version of Google Play(down below).

查看最新版本的 Google Play(如下)。

They are using the SlidingTabsColors(not SlidingTabsBasic) but with colors. You need to look at those two files: SlidingTabLayout.javaand SlidingTabStrip.javaand simply change the color to match your ActionBar/TooBar color.

他们使用的是SlidingTabsColors(不是 SlidingTabsBasic),而是带有颜色。您需要查看这两个文件:SlidingTabLayout.javaSlidingTabStrip.java简单地更改颜色以匹配您的 ActionBar/TooBar 颜色。

Also, you will notice when you swipe left/right, the Tab title text color will become "white" and the unselected titles are an "gray" color.

此外,您会注意到,当您向左/向右滑动时,选项卡标题文本颜色将变为“白色”,而未选择的标题将变为“灰色”。

For example(how to change the indicator color):

例如(如何更改指示器颜色):

class SlidingTabStrip extends LinearLayout {
    // change the strip color
    private static final int DEFAULT_SELECTED_INDICATOR_COLOR = 0xFF33B5E5;
   ...
}

Please see the example here: https://developer.android.com/samples/SlidingTabsColors/index.html

请在此处查看示例:https: //developer.android.com/samples/SlidingTabsColors/index.html

Google Play Store

谷歌商店

Please read these as well:

请同时阅读以下内容:

Android - Google Play like tabs

Android - Google Play like tabs

Action bar navigation modes are deprecated in Android L

Android L 中不推荐使用操作栏导航模式

回答by LOG_TAG

You are looking for this material design tabs Right?

您正在寻找这种材料设计标签对吗?

Have a look at this..

看看这个..

enter image description here

在此处输入图片说明

FYI material design tabs can found in this repo jpardogo's PagerSlidingTabStrip

仅供参考,材料设计选项卡可以在此 repo jpardogo 的 PagerSlidingTabStrip 中找到

Update:Mr.Jpardogohim self answered in SOpost click here

更新:Jpardogo 先生他自己在SO帖子中回答了点击这里

Credits: Mr.Javier Pardo de Santayana Gómez

致谢:Javier Pardo de Santayana Gómez 先生