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