<?xml version="1.0" encoding="utf-8"?>
<com.zhy.autolayout.AutoLinearLayout
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/color_white"
android:fitsSystemWindows="true"
android:orientation="vertical">
<com.zhy.autolayout.AutoLinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/title_height"
android:orientation="horizontal">
<ImageView
android:layout_width="120px"
android:layout_height="60px"
android:layout_gravity="center_vertical"
android:scaleType="fitCenter"
android:src="@mipmap/home_icon_my" />
<com.zhy.autolayout.AutoLinearLayout
android:id="@+id/ll_search"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_marginBottom="10px"
android:layout_marginTop="10px"
android:layout_weight="1"
android:background="@drawable/shape_tab_home"
android:clickable="true"
android:descendantFocusability="beforeDescendants"
android:orientation="horizontal">
<ImageView
android:layout_width="32px"
android:layout_height="32px"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/public_spacing_20"
android:layout_marginRight="@dimen/public_spacing_20"
android:clickable="false"
android:src="@mipmap/home_icon_seach" />
<TextView
android:id="@+id/et_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/public_spacing_20"
android:background="@null"
android:clickable="false"
android:focusable="false"
android:text="请输入你想要查询的商品"
android:textColor="@color/color_9"
android:textSize="@dimen/font_text_24px" />
</com.zhy.autolayout.AutoLinearLayout>
<com.zhy.autolayout.AutoLinearLayout
android:id="@+id/ll_kefu"
android:layout_width="120px"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical">
<ImageView
android:layout_width="32px"
android:layout_height="32px"
android:layout_gravity="center_horizontal"
android:src="@mipmap/home_icon_kf" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/margin_10"
android:text="@string/str_im"
android:textColor="@color/color_login"
android:textSize="@dimen/font_text_20px" />
</com.zhy.autolayout.AutoLinearLayout>
</com.zhy.autolayout.AutoLinearLayout>
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.zhy.autolayout.AutoRelativeLayout
android:id="@+id/rl_fragment_home"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/cl_fragment_home"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"
app:layout_behavior="com.ydt.moiiee.utils.FlingBehavior">
<com.zhy.autolayout.AutoLinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_scrollFlags="scroll">
<com.youth.banner.Banner
android:id="@+id/banner"
android:layout_width="match_parent"
android:layout_height="300px"
android:background="@color/color_white"
android:minHeight="300px"
app:indicator_drawable_selected="@drawable/rectangle_gray"
app:indicator_drawable_unselected="@drawable/rectangle_write"
app:indicator_height="5dp"
app:indicator_margin="5dp"
app:indicator_width="5dp" />
<com.zhy.autolayout.AutoLinearLayout
android:layout_width="match_parent"
android:layout_height="160px"
android:orientation="horizontal">
<com.zhy.autolayout.AutoLinearLayout
android:id="@+id/ll_home_group_high"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_home_group_high"
android:layout_width="40px"
android:layout_height="40px"
android:layout_gravity="center_horizontal"
android:src="@mipmap/icon_home_gddz" />
<TextView
android:id="@+id/tv_home_group_high"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/margin_10"
android:text="@string/str_group_high"
android:textColor="@color/color_22"
android:textSize="@dimen/font_text_24px" />
</com.zhy.autolayout.AutoLinearLayout>
<com.zhy.autolayout.AutoLinearLayout
android:id="@+id/ll_home_group_custom"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_home_group_custom"
android:layout_width="40px"
android:layout_height="40px"
android:layout_gravity="center_horizontal"
android:src="@mipmap/home_icon_group_custom" />
<TextView
android:id="@+id/tv_home_group_custom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/margin_10"
android:text="@string/str_group_custom"
android:textColor="@color/color_22"
android:textSize="@dimen/font_text_24px" />
</com.zhy.autolayout.AutoLinearLayout>
<com.zhy.autolayout.AutoLinearLayout
android:id="@+id/btn_measure"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
<ImageView
android:layout_width="40px"
android:layout_height="40px"
android:layout_gravity="center_horizontal"
android:src="@mipmap/home_icon_lt" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/margin_10"
android:text="@string/str_measurement_free"
android:textColor="@color/color_22"
android:textSize="@dimen/font_text_24px" />
</com.zhy.autolayout.AutoLinearLayout>
<com.zhy.autolayout.AutoLinearLayout
android:id="@+id/btn_custom"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
<ImageView
android:layout_width="40px"
android:layout_height="40px"
android:layout_gravity="center_horizontal"
android:src="@mipmap/home_icon_dz" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/margin_10"
android:text="@string/str_customization"
android:textColor="@color/color_22"
android:textSize="@dimen/font_text_24px" />
</com.zhy.autolayout.AutoLinearLayout>
<com.zhy.autolayout.AutoLinearLayout
android:id="@+id/ll_home_points_shop"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:id="@+id/iv_home_points"
android:layout_width="40px"
android:layout_height="40px"
android:layout_gravity="center_horizontal"
android:src="@mipmap/home_icon_jf" />
<TextView
android:id="@+id/tv_home_points"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/margin_10"
android:text="@string/str_bonus_points"
android:textColor="@color/color_22"
android:textSize="@dimen/font_text_24px" />
</com.zhy.autolayout.AutoLinearLayout>
</com.zhy.autolayout.AutoLinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="20px"
android:background="@color/color_divider" />
<com.zhy.autolayout.AutoRelativeLayout
android:layout_width="match_parent"
android:layout_height="100px"
android:padding="@dimen/margin_20">
<com.zhy.autolayout.AutoLinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:orientation="horizontal">
<View
android:layout_width="@dimen/px8"
android:layout_height="@dimen/px32"
android:layout_gravity="center_vertical"
android:background="@color/color_283" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingLeft="@dimen/margin_10"
android:text="@string/str_customization_by_brand"
android:textColor="@color/color_283"
android:textSize="@dimen/font_text_30px" />
</com.zhy.autolayout.AutoLinearLayout>
<Button
android:id="@+id/btn_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@null"
android:drawablePadding="10px"
android:drawableRight="@mipmap/home_icon_more"
android:text="@string/str_see_more"
android:textColor="@color/color_99"
android:textSize="@dimen/font_text_30px" />
</com.zhy.autolayout.AutoRelativeLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/nsv_fragment_home"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_banner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_white"
android:paddingBottom="40px"
android:paddingLeft="@dimen/margin_20"
android:paddingRight="@dimen/margin_20" />
</android.support.v4.widget.NestedScrollView>
<View
android:layout_width="match_parent"
android:layout_height="20px"
android:background="@color/color_divider" />
<!-- 高端定制 -->
<com.zhy.autolayout.AutoRelativeLayout
android:layout_width="match_parent"
android:layout_height="100px"
android:padding="@dimen/margin_20">
<com.zhy.autolayout.AutoLinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:orientation="horizontal">
<View
android:layout_width="@dimen/px8"
android:layout_height="@dimen/px32"
android:layout_gravity="center_vertical"
android:background="@color/color_283" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingLeft="@dimen/margin_10"
android:text="@string/str_customization_by_high"
android:textColor="@color/color_283"
android:textSize="@dimen/font_text_30px" />
</com.zhy.autolayout.AutoLinearLayout>
<Button
android:id="@+id/btn_high_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@null"
android:drawablePadding="10px"
android:drawableRight="@mipmap/home_icon_more"
android:text="@string/str_see_more"
android:textColor="@color/color_99"
android:textSize="@dimen/font_text_30px" />
</com.zhy.autolayout.AutoRelativeLayout>
<ImageView
android:id="@+id/iv_high_head"
android:layout_width="match_parent"
android:layout_height="@dimen/px300"
android:scaleType="fitXY" />
<com.zhy.autolayout.AutoLinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/px200"
android:layout_marginLeft="@dimen/px10"
android:layout_marginRight="@dimen/px10"
android:layout_marginTop="@dimen/px10">
<ImageView
android:id="@+id/iv_high_left"
android:layout_width="0px"
android:layout_height="@dimen/px200"
android:layout_marginRight="@dimen/px10"
android:layout_weight="1"
android:scaleType="fitXY" />
<ImageView
android:id="@+id/iv_high_right"
android:layout_width="0px"
android:layout_height="@dimen/px200"
android:layout_weight="1"
android:scaleType="fitXY" />
</com.zhy.autolayout.AutoLinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="20px"
android:layout_marginTop="@dimen/px40"
android:background="@color/color_divider" />
<com.zhy.autolayout.AutoRelativeLayout
android:layout_width="wrap_content"
android:layout_height="100px"
android:layout_gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="@dimen/margin_20">
<com.zhy.autolayout.AutoLinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:orientation="horizontal">
<View
android:layout_width="@dimen/px8"
android:layout_height="@dimen/px32"
android:layout_gravity="center_vertical"
android:background="@color/color_283" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingLeft="@dimen/margin_10"
android:text="定制新品"
android:textColor="@color/color_283"
android:textSize="@dimen/font_text_30px" />
</com.zhy.autolayout.AutoLinearLayout>
<Button
android:id="@+id/btn_new_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@null"
android:drawablePadding="10px"
android:drawableRight="@mipmap/home_icon_more"
android:text="@string/str_see_more"
android:textColor="@color/color_99"
android:textSize="@dimen/font_text_30px" />
</com.zhy.autolayout.AutoRelativeLayout>
<com.ydt.common.widget.autolayout.AutoNestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_customization"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/margin_20"
android:paddingRight="@dimen/margin_20" />
</com.ydt.common.widget.autolayout.AutoNestedScrollView>
<View
android:layout_width="match_parent"
android:layout_height="20px"
android:background="@color/color_divider" />
<com.zhy.autolayout.AutoRelativeLayout
android:layout_width="wrap_content"
android:layout_height="100px"
android:layout_gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="@dimen/px20"
android:paddingRight="@dimen/px20">
<com.zhy.autolayout.AutoLinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<View
android:layout_width="@dimen/px8"
android:layout_height="@dimen/px32"
android:layout_gravity="center_vertical"
android:background="@color/color_283" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingLeft="@dimen/margin_10"
android:text="发现精彩"
android:textColor="@color/color_283"
android:textSize="@dimen/font_text_30px" />
</com.zhy.autolayout.AutoLinearLayout>
<Button
android:id="@+id/btn_jx_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@null"
android:drawablePadding="10px"
android:drawableRight="@mipmap/home_icon_more"
android:text="@string/str_see_more"
android:textColor="@color/color_99"
android:textSize="@dimen/font_text_30px" />
</com.zhy.autolayout.AutoRelativeLayout>
<com.ydt.common.widget.autolayout.AutoNestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_moyun"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/margin_20" />
</com.ydt.common.widget.autolayout.AutoNestedScrollView>
<View
android:layout_width="match_parent"
android:layout_height="20px"
android:background="@color/color_divider" />
</com.zhy.autolayout.AutoLinearLayout>
<com.ydt.common.widget.autolayout.AutoTabLayout
android:id="@+id/tabloyout"
android:layout_width="match_parent"
android:layout_height="@dimen/px100"
android:layout_below="@id/toolbar"
android:layout_gravity="bottom"
android:background="@color/color_white"
android:fillViewport="false"
android:focusable="false"
android:scrollbars="none"
app:tabGravity="fill"
app:tabIndicatorColor="@color/color_login"
app:tabIndicatorHeight="@dimen/px4"
app:tabPaddingEnd="@dimen/px20"
app:tabPaddingStart="@dimen/px20"
app:tabSelectedTextColor="@color/color_login"
app:tabTextAppearance="@style/StoreTabLayoutTextAppearance"
app:tabTextColor="@color/color_55" />
<include layout="@layout/divider" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_recommend"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/margin_20"
android:paddingRight="@dimen/margin_20"
android:paddingTop="@dimen/margin_20" />
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
<ImageView
android:id="@+id/iv_top"
android:layout_width="@dimen/public_spacing_80"
android:layout_height="@dimen/public_spacing_80"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="@dimen/search_height_60px"
android:layout_marginRight="@dimen/public_spacing_20"
android:clickable="true"
android:src="@mipmap/home_btn_top" />
</com.zhy.autolayout.AutoRelativeLayout>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
解决方法:
iv_top.setOnClickListener {
var behavior = (app_bar_layout.layoutParams as CoordinatorLayout.LayoutParams).behavior
if (behavior is AppBarLayout.Behavior) {
var appBarLayoutBehavior = behavior
var topAndBottomOffset = appBarLayoutBehavior.topAndBottomOffset;
if (topAndBottomOffset != 0) {
appBarLayoutBehavior.topAndBottomOffset = 0
}
}
}
关键代码:
appBarLayoutBehavior.topAndBottomOffset = 0