android 5.0 toolbar 上实现 material tabs

android5.0 中如何才能实现类似play store中的tab效果?(滚动式隐藏,合适的间距),我尝试过 SlidingTabs 和其他的一些lib库,他们基本上都超期了..

关于一些细节方面,android5之前的版本中,api20一下,我经常使用 actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); ,但是在android5.0中,整个ActionBar  都被ToolBar替换了

.

如何才能正确的使用 Material Design 做出类似 google paly store的效果? android 5中如何让tabs在滚动的时候隐藏?

处理方法

他们的layout如下,基本上是这样的,达不到和 play store完美一样的程序

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/my_awesome_toolbar"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:minHeight="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:theme="@style/ThemeOverlay.AppCompat.ActionBar">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:text="@string/hello_world"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title" />

            <widget.SlidingTabLayout
                android:id="@+id/sliding_tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />
        </LinearLayout>
    </android.support.v7.widget.Toolbar>

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:paddingBottom="@dimen/activity_vertical_margin">

        <TextView
            android:text="@string/hello_world"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <android.support.v4.view.ViewPager
            android:id="@+id/ViewPager"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </LinearLayout>
</LinearLayout>

原文地址:http://www.itmmd.com/201411/209.html

该文章由 萌萌的IT人 整理发布,转载须标明出处。

时间: 2024-07-30 10:17:52

android 5.0 toolbar 上实现 material tabs的相关文章

在Android 6.0 设备上动态获取权限

众所周知,Android 6.0 相比之前的Android版本有一个很大的不同点,就是动态获取权限.最近要修改原来的程序适配安卓6.0+.以记录下在Android 6.0 上如何动态获取权限. 下面从自己一开始的问题入手 实现拨号功能 说到拨号,一个 Intent 就搞定,代码如下, 1 2 3 4 5 6 private void callDirectly(String mobile){ Intent intent = new Intent(); intent.setAction("andro

android 4.0.x上AnimatorSet.setDuration上的坑

<span style="font-size:18px;">  </span> <span style="font-size:18px;"> 最近在用<a target=_blank href="https://github.com/skyfishjy/android-ripple-background">https://github.com/skyfishjy/android-ripple-bac

ym—— Android 5.0学习之使用Material主题

前言 创建完模拟器了,我想大家已经迫不及待的想开发Android 5.0的项目了, 看完这篇后我们将可以自定义Material主题了~! 新的material主题提供了什么? 可以让你设置调色板的系统控件. 为控件(设计的)触摸反馈动画. Activity过渡动画 我们来看一下Android给我提供了多少Material的主题吧~! 看来给我不少常用的主题,但是这些主题远远满足不了我大佬们的需求~!至于为什么,我想大家都懂得. 让我们来自定义Material主题吧 根据官方提供图片提示的来自定义

Android开发:Toolbar基本使用和自定义Toolbar

Toolbar简介 Toolbar 是 Android 5.0 推出的一个 Material Design 风格的导航控件 ,用来取代之前的 Actionbar .与 Actionbar 相比,Toolbar 明显要灵活的多.它不像 Actionbar 一样,一定要固定在Activity的顶部,而是可以放到界面的任意位置,看下官方文档介绍: 注意看着几部分: - 1.设置导航栏图标: - 2.设置App的logo: - 3.支持设置标题和子标题: - 4.支持添加一个或多个的自定义控件: - 5

Android 5.0特性

虽然此前Google对其已经做过了比较深入的介绍,但作为一个如此重要的升级版本,更新内容自然是海量的. Google今天很贴心地在官网上放出了Android 5.0正式版的完整更新日志,涵盖了升级的方方面面,不过说实话也只是一些重要的.大面上的概略更新介绍,还有更多细节等待挖掘. 1.Material Design 醒目的.多彩的.快速响应的UI设计,可为你所有的设备带来一致的直觉体验. - 响应快速.自然流畅的动作,真实的光照和阴影,熟悉的视觉元素,设备导航更加轻而易举. - 惊艳的新色彩,凸

android 5.0 新特性

android 5.0 的新特性 Material Design: Gives you and unexpanded UI toolkit for integrating the new degin patterns easily in your apps New 3D views let you ser a z-level to raise elements off of the view hierarchy and cast reltime shadows ,even ad they mov

Android 7.0 Nougat(牛轧糖)---对开发者来说

android 7.0出来了.让你的app准备迎接最新的android版本吧,支持节省电量和内存,这样新的系统行为.使用多窗口UI.直接恢复通知以及其他操作来扩展你的app. android 7.0介绍了各种各样的新功能给用户和开发者, 本文重点介绍面向开发者的一些新功能. 确保检查android 7.0的行为变化,了解有关平台的变化可能会影响你的app. 如果要了解更多的关于用户的新功能,请查看www.android.com. 1.支持多窗口 在android 7.0中,我们介绍了在支持多窗口

Android开发之深入理解Android 7.0系统权限更改相关文档

摘要: Android 6.0之后的版本增加了运行时权限,应用程序在执行每个需要系统权限的功能时,需要添加权限请求代码(默认权限禁止),否则应用程序无法响应:Android 7.0在Android 6.0的基础上,对系统权限进一步更改,这次的权限更改包括三个方面: APP应用程序的私有文件不再向使用者放宽 Intent组件传递file://URI的方式可能给接收器留下无法访问的路径,触发FileUriExposedException异常,推荐使用FileProvider DownloadMana

Android 6.0.x 系统安装xpoesd框架

万物基于xpoesd框架 1.工具 安卓6.0手机 xpoesd框架安装包 2.下载地址 点击此处下载xpoesd for android 6.0.x 无法连接外网的也可以使用点此百度云 提取密码:r3mh 3.安装方法 1.将文件解压,并拷入手机.最好拷入手机根目录. 2.进入recovery,找到xpoesd安装包,安装zip包.安装方法就像安装普通刷机包一样.如下图: -1进入recovery模式 -2recovery为twrp3.0.0 -3点击install,从目录中找到xpoesd安