android 安卓客户端 首页的动态toolbar是如何实现的?
高洛峰
高洛峰 2017-04-17 14:50:57
[Android讨论组]

我也不知道是不是叫这个名字,希望大神指点,就是下拉时出现上划时移动隐藏,好多app都有,谢谢

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

全部回复(4)
ringa_lee

外层CoordinatorLayout 里层AppbarLayout 然后Toolbar

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
             xmlns:app="http://schemas.android.com/apk/res-auto"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:background="@color/primary">
    <android.support.v4.widget.DrawerLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/drawer_layout">

        <android.support.design.widget.CoordinatorLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.v4.view.ViewPager
                android:id="@+id/pager"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_behavior="@string/appbar_scrolling_view_behavior" />

            <android.support.design.widget.AppBarLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:theme="@style/AppTheme.AppBarOverlay"
                app:elevation="0dp">

                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:background="?attr/colorPrimary"
                    android:minHeight="?attr/actionBarSize"
                    app:layout_scrollFlags="scroll|enterAlways" />

                <android.support.design.widget.TabLayout
                    android:id="@+id/layout_tab"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:tabIndicatorColor="#33000000"
                    app:tabIndicatorHeight="4dp"
                    app:tabPaddingBottom="0dp"
                    app:tabPaddingEnd="0dp"
                    app:tabPaddingStart="0dp"
                    app:tabPaddingTop="0dp"
                    app:tabSelectedTextColor="#fff"
                    app:tabGravity="fill"
                    app:tabTextColor="#fff" />

            </android.support.design.widget.AppBarLayout>

        </android.support.design.widget.CoordinatorLayout>

        <fragment
            android:name="com.segmentfault.app.fragment.MineFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="start" />

    </android.support.v4.widget.DrawerLayout>
    <fragment
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:name="com.segmentfault.app.fragment.SplashFragment"
        android:id="@+id/splash_fragment" />

</FrameLayout>

(没有比贴SegmentFault for Android源码更有诚意的了吧?

PHP中文网

v7的toolbar

迷茫

外层用 CoordinatorLayout,内部嵌套 Toolbar。

具体可以参考这篇博客:http://blog.csdn.net/u010687392/article/details/46852565

天蓬老师

http://www.jianshu.com/p/1078568e859f?utm_source=jianliao.com

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号