悬浮指示器布局-利用协调器布局

简介: 现在仿360手机助手,简书布局效果的案例,越来越多,之前我写过FloatIndicatorLayout,发出来之后,还是有不少朋友在看,也有朋友告诉我可以用CoordinatorLayout去实现这个效果,之前对协调器布局了解的比较少,这两天抽空看了...

现在仿360手机助手,简书布局效果的案例,越来越多,之前我写过FloatIndicatorLayout,发出来之后,还是有不少朋友在看,也有朋友告诉我可以用CoordinatorLayout去实现这个效果,之前对协调器布局了解的比较少,这两天抽空看了一下,不仅感慨,还是谷歌的大神牛逼!

先看png预览,这里是 gif效果图源码

Paste_Image.png

再看代码

<pre>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cool="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/co_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

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

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/co_to_layout"
        android:layout_width="match_parent"
        android:layout_height="270dp"
        android:background="#DD009688"
        cool:collapsedTitleTextAppearance="@style/ToolBarTitleText"
        cool:contentScrim="#009688"
        cool:expandedTitleMarginEnd="48dp"
        cool:expandedTitleMarginStart="48dp"
        cool:expandedTitleTextAppearance="@style/transparentText"
        cool:layout_scrollFlags="scroll|enterAlways">
        <!-- cool:layout_scrollFlags="scroll|exitUntilCollapsed"-->


        <LinearLayout
            android:id="@+id/layout_head"
            cool:layout_collapseMode="pin"
            cool:layout_collapseParallaxMultiplier="0.7">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="50dp"
                android:padding="20dp">

            
            </RelativeLayout>
        </LinearLayout>

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            cool:layout_collapseMode="pin"
            cool:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            cool:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>

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

    <View
        android:layout_width="match_parent"
        android:layout_height="0.5dp"
        android:background="#EE009688"/>

    <github.hellojp.tabsindicator.TabsIndicator
        xmlns:tabsIndicator="http://schemas.android.com/apk/res-auto"
        android:id="@+id/ti"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:layout_gravity="bottom"
        android:background="#009688"
        tabsIndicator:dividerColor="#E0F2F1"
        tabsIndicator:dividerVerticalMargin="10dp"
        tabsIndicator:dividerWidth="2dp"
        tabsIndicator:hasDivider="true"
        tabsIndicator:lineColor="#00695C"
        tabsIndicator:lineHeight="2dp"
        tabsIndicator:lineMarginTab="20dp"
        tabsIndicator:linePosition="bottom"
        tabsIndicator:textBackgroundResId="@drawable/selector_view_tabs_item"
        tabsIndicator:textColor="@drawable/selector_tab"
        tabsIndicator:textSizeNormal="14sp"
        tabsIndicator:textSizeSelected="18sp"/>
</android.support.design.widget.AppBarLayout>


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

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

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

<github.aspsine.swipetoloadlayout.SwipeToLoadLayout
    xmlns:swipeToLoadLayout="http://schemas.android.com/apk/res-auto"
    android:id="@+id/stll"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    swipeToLoadLayout:default_to_loading_more_scrolling_duration="500"
    swipeToLoadLayout:default_to_refreshing_scrolling_duration="1000"
    swipeToLoadLayout:load_more_complete_delay_duration="0"
    swipeToLoadLayout:load_more_final_drag_offset="@dimen/load_more_final_offset_google"
    swipeToLoadLayout:load_more_trigger_offset="@dimen/load_more_trigger_offset_google"
    swipeToLoadLayout:refresh_complete_delay_duration="0"
    swipeToLoadLayout:refresh_final_drag_offset="@dimen/refresh_final_offset_google"
    swipeToLoadLayout:refresh_trigger_offset="@dimen/refresh_trigger_offset_google"
    swipeToLoadLayout:swipe_style="above">

    <include
        android:id="@id/swipe_refresh_header"
        layout="@layout/layout_google_hook_header"
        />

    <android.support.v7.widget.RecyclerView
        android:id="@+id/swipe_target"
        tools:listitem="@layout/item_fragment_game_before_score"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    <include
        android:id="@id/swipe_load_more_footer"
        layout="@layout/layout_google_footer"
        />

</github.aspsine.swipetoloadlayout.SwipeToLoadLayout>

</LinearLayout>
</pre>

目录
相关文章
|
3月前
|
前端开发 容器
如何实现一个两栏布局,右侧自适应?三栏布局中间自适应?
要实现一个两栏布局,右侧自适应的效果,可以使用 CSS 的 Flexbox 或 Grid 布局来实现。以下是使用 Flexbox 实现的示例:
28 1
|
4月前
【sgDragMove】自定义组件:自定义拖拽组件,仅支持拖拽、设置吸附屏幕边界距离。
【sgDragMove】自定义组件:自定义拖拽组件,仅支持拖拽、设置吸附屏幕边界距离。
|
4月前
[Qt5&布局] 控件自动填满所在布局框架
[Qt5&布局] 控件自动填满所在布局框架
35 0
[Qt5&布局] 控件自动填满所在布局框架
|
6月前
|
UED 容器
如何实现侧边两栏宽度固定,中间栏宽度自适应的布局?——双飞翼布局、圣杯(Holy Grails)布局
如何实现侧边两栏宽度固定,中间栏宽度自适应的布局?——双飞翼布局、圣杯(Holy Grails)布局
43 0
|
8月前
|
前端开发 容器
两栏布局的实现方式
两栏布局的实现方式
|
10月前
|
编解码 前端开发 Android开发
移动布局基础(流式布局)
移动布局基础(流式布局)
100 0
|
JavaScript 前端开发
鼠标拖拽菜单栏控制宽度大小及flex实现经典左右两栏布局
鼠标拖拽菜单栏控制宽度大小及flex实现经典左右两栏布局
鼠标拖拽菜单栏控制宽度大小及flex实现经典左右两栏布局
【Flutter】监听滚动动作 控制组件 透明度渐变 ( 移除顶部状态栏空白 | 帧布局组件 | 透明度组件 | 监听滚动组件 )(二)
【Flutter】监听滚动动作 控制组件 透明度渐变 ( 移除顶部状态栏空白 | 帧布局组件 | 透明度组件 | 监听滚动组件 )(二)
224 0
|
Dart 开发者
【Flutter】监听滚动动作 控制组件 透明度渐变 ( 移除顶部状态栏空白 | 帧布局组件 | 透明度组件 | 监听滚动组件 )(三)
【Flutter】监听滚动动作 控制组件 透明度渐变 ( 移除顶部状态栏空白 | 帧布局组件 | 透明度组件 | 监听滚动组件 )(三)
195 0
【Flutter】监听滚动动作 控制组件 透明度渐变 ( 移除顶部状态栏空白 | 帧布局组件 | 透明度组件 | 监听滚动组件 )(三)