android 5.0 材料设计标签 [英] android 5.0 material design tabs

查看:27
本文介绍了android 5.0 材料设计标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在最新的 Google NewsStand 应用中实现 Material Design 风格标签的最佳和简单方法是什么?这正是我正在寻找的,但不知道从哪里开始.非常感谢提供的任何帮助/方向.谢谢.

What is the best and easy way to implement material design style tabs just like in the latest Google NewsStand app? That is exactly what I'm looking for but don't know where to start. Any help/direction provided is greatly appreciated. Thanks.

推荐答案

@ChrisBanes (Developer Programs Engineer for Android)用新的工具栏解释情况.

This post of @ChrisBanes (Developer Programs Engineer for Android) explain the situation with the new Toolbar.

所以这个示例可以提供帮助.

So this sample can help.

以及这个 DevBytes 视频.

As well as this DevBytes video.

如果你想要一个库,你可以去这个但它没有更新到材料设计(我分叉了它,如果我有时间,我会尝试更新它).

If you want a library, you can go for this one but It is not updated to material design (I forked it, and If I have some time, I will try to update it).

您可以在 @ChrisBanes 博客 以及 安卓官方博客

您可以在此 repo jpardogo/PagerSlidingTabStrip 中找到材料设计选项卡:

You can find material design tabs in this repo jpardogo/PagerSlidingTabStrip :

到目前为止,我基本上对原始库进行了 4 次更改(我将添加 Toolbar 并在明天修复一些内容):

I basically did 4 changes to the original library, so far (I will add Toolbar and fix some stuff tomorrow):

  1. 更改选项卡布局的默认参数,使其看起来更有质感.
  2. 在滑动选项卡时,指示器默认居中.
  3. 标题的 alpha 值会根据所选位置而变化.
  4. 能够传递在您的适配器中实现接口CustomTabProvider"的 customTabs.

  1. Change the default parameters of the tabs layout to make it look like more material.
  2. The indicator is center by default while swiping tabs.
  3. The alpha value of the titles change depending the selected position.
  4. Ability to pass customTabs implementing the interface ´CustomTabProvider` in your adapter.

  • 如果 customTab 有一个 ID 为 @+id/tab_title 的视图,它将用于放置标题,而 alpha 将照常运行.
  • 如果此接口未实现,则将使用默认的 Tab 布局(TextView).
  • In case the customTab have a view with id @+id/tab_title, it will be use to place the title and alpha will act as usual.
  • If this interface is not implemented then, the default Tab layout will be use (TextView).

如果您愿意,可以使用任何这些库来使用带有涟漪的自定义选项卡:

If you want you can use a custom tab with ripples using any of this libraries:

我更改了新支持库 Toolbar 的 ActionBar.我还动态地将颜色应用于选项卡、工具栏和状态栏.您可以在以下 gif 中看到在 android 4.4.3 中运行的示例.

I changed the ActionBar for the new support library Tooolbar. I have also applied colors dynamically to the tabs,toolbar and statusBar. You can see the example working in android 4.4.3 on the following gif.

我发送了一份包含我的更改的 PR.如果原项目所有者不更新 maven 库,并将其推送到 maven,我会将我的库 fork 推送到 maven central.

I sent a PR with my changes. If the original project owner doesn't update the maven library, and push it to maven I will push my library fork to maven central.

这篇关于android 5.0 材料设计标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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