悬浮 顶部的 scrollView

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/lijinweii/article/details/102736985

今天状态不好 感冒了 直接先看效果效果吧

第一第二企业

第四

布局

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <data>

        <import type="android.view.View" />

        <import type="android.text.TextUtils" />

        <variable
            name="bean"
            type="com.program.ccmei.bean.FactoryDetailBean.DataBean" />

    </data>

    <RelativeLayout
        android:id="@+id/rl_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/white">

        <com.program.ccmei.view.SuspensionTopScrollView
            android:id="@+id/scrollView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@+id/ll_sign_up">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginBottom="50dp"
                android:orientation="vertical">

                <FrameLayout
                    android:id="@+id/fl_img"
                    android:layout_width="match_parent"
                    android:layout_height="300dp">

                    <com.youth.banner.Banner
                        android:id="@+id/banner_img"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        app:banner_layout="@layout/banner_custom_viewpager"
                        app:image_scale_type="center_crop"
                        app:indicator_drawable_selected="@mipmap/ic_right_red"
                        app:indicator_height="6dp"
                        app:indicator_margin="3dp"
                        app:indicator_width="6dp" />

                    <include
                        android:id="@+id/tb_transparency"
                        layout="@layout/toolbar_transparency" />

                    <TextView
                        android:id="@+id/tv_img_count"
                        android:layout_width="match_parent"
                        android:layout_height="40dp"
                        android:layout_gravity="bottom"
                        android:background="#66000000"
                        android:gravity="center_vertical|right"
                        android:paddingRight="@dimen/margin"
                        android:text="@{bean.imgCount}"
                        android:textColor="@color/white"
                        android:textSize="@dimen/textSize12" />

                </FrameLayout>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/margin"
                    android:layout_marginTop="10dp"
                    android:text="@{bean.title}"
                    android:includeFontPadding="false"
                    android:textColor="@color/black"
                    android:textSize="@dimen/textSize18"
                    tools:text="@tools:sample/full_names" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/margin"
                    android:layout_marginTop="@dimen/margin8"
                    android:layout_marginRight="@dimen/margin"
                    android:includeFontPadding="false"
                    android:layout_marginBottom="@dimen/margin8"
                    android:text="@{bean.salary_str}"
                    android:textColor="@color/colorPrimary"
                    android:textSize="@dimen/textSize18"
                    tools:text="@tools:sample/full_names" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/margin"
                    android:text="@string/time"
                    android:textColor="@color/commonText9"
                    android:textSize="@dimen/textSize12"
                    android:visibility="gone" />

                <View
                    style="@style/CommonLine"
                    android:layout_marginLeft="@dimen/margin"
                    android:layout_marginRight="@dimen/margin"
                    android:layout_marginBottom="@dimen/margin8" />

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingLeft="@dimen/margin"
                    android:paddingRight="@dimen/margin">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="招聘人数:"
                        android:textColor="@color/commonText6"
                        android:textSize="@dimen/textSize15" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="10dp"
                        android:text="@{bean.total_nums}"
                        android:textColor="@color/black"
                        android:textSize="@dimen/textSize15"
                        tools:text="@tools:sample/full_names" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@{bean.signup_nums}"
                        android:textColor="@color/commonText9"
                        android:textSize="@dimen/textSize15"
                        tools:text="@tools:sample/full_names" />

                </LinearLayout>


                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingLeft="@dimen/margin"
                    android:paddingTop="@dimen/margin8"
                    android:paddingRight="@dimen/margin"
                    android:paddingBottom="@dimen/margin8">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="招聘要求:"
                        android:textColor="@color/commonText6"
                        android:textSize="@dimen/textSize15" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="10dp"
                        android:text="@{bean.sex_str+@string/ge+bean.age_str}"
                        android:textColor="@color/black"
                        android:textSize="@dimen/textSize15"
                        tools:text="@tools:sample/full_names" />

                </LinearLayout>

                <LinearLayout
                    android:id="@+id/ll_job_tag"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingLeft="@dimen/margin"
                    android:paddingRight="@dimen/margin">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="福利:"
                        android:textColor="@color/commonText6"
                        android:textSize="@dimen/textSize15" />

                    <com.program.ccmei.utils.FlowRadioGroup
                        android:id="@+id/frg_job"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="10dp" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="40dp"
                    android:layout_marginTop="10dp"
                    android:background="@color/colorPageBg"
                    android:gravity="center_vertical"
                    android:paddingLeft="@dimen/margin"
                    android:paddingRight="@dimen/margin">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:drawableLeft="@mipmap/ic_loc"
                        android:drawablePadding="5dp"
                        android:ellipsize="end"
                        android:lines="1"
                        android:text="@{bean.address}"
                        android:textColor="@color/commonText6"
                        android:textSize="@dimen/textSize16" />

                    <TextView
                        android:id="@+id/tv_loc"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/textSize15"
                        android:text="查看位置"
                        android:textColor="@color/blue"
                        android:textSize="@dimen/textSize16" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="76dp"
                    android:gravity="center_vertical"
                    android:paddingLeft="@dimen/margin"
                    android:paddingRight="@dimen/margin">

                    <ImageView
                        android:layout_width="50dp"
                        android:layout_height="40dp"
                        android:displayImage="@{bean.fac_logo_img}"
                        android:scaleType="fitXY" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/margin"
                        android:layout_weight="1"
                        android:text="@{bean.cname}"
                        android:textColor="@color/black"
                        android:textSize="@dimen/textSize18" />

                    <TextView
                        android:id="@+id/tv_enterprise_detail"
                        android:layout_width="75dp"
                        android:layout_height="25dp"
                        android:background="@drawable/enterprise_bg"
                        android:gravity="center"
                        android:text="企业详情"
                        android:textColor="@color/colorPrimary"
                        android:textSize="@dimen/textSize14" />

                </LinearLayout>

                <LinearLayout
                    android:id="@+id/ll_salary_content"
                    android:layout_width="match_parent"
                    android:layout_height="44dp"
                    android:background="@color/colorPageBg"
                    android:gravity="center">

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@mipmap/ic_left_line" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/margin"
                        android:layout_marginRight="@dimen/margin"
                        android:drawableLeft="@mipmap/ic_salary"
                        android:drawablePadding="10dp"
                        android:text="工资情况"
                        android:textColor="@color/commonText9"
                        android:textSize="@dimen/textSize13" />

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@mipmap/ic_right_line" />

                </LinearLayout>

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="45dp"
                    android:drawableLeft="@mipmap/ic_one"
                    android:drawablePadding="@dimen/margin"
                    android:gravity="center_vertical"
                    android:paddingLeft="@dimen/margin"
                    android:text="我能挣多少钱?"
                    android:textColor="@color/color010101"
                    android:textSize="@dimen/textSize16" />

                <View style="@style/CommonLine" />

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/margin"
                    android:paddingLeft="@dimen/margin">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="综合工资:"
                        android:textColor="@color/commonText6"
                        android:textSize="@dimen/textSize15" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@{bean.salary_str}"
                        android:textColor="@color/colorPrimary"
                        android:textSize="@dimen/textSize15" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/margin"
                    android:paddingLeft="@dimen/margin"
                    android:visibility="@{bean.salary_type!=0?View.VISIBLE:View.GONE}">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="小  时  工:"
                        android:textColor="@color/commonText6"
                        android:textSize="@dimen/textSize15" />

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

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

                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="@{bean.salary_hour}"
                                android:textColor="@color/colorPrimary"
                                android:textSize="@dimen/textSize15" />

                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginLeft="@dimen/margin"
                                android:text="月工资"
                                android:textColor="@color/black"
                                android:textSize="@dimen/textSize15"
                                android:visibility="@{TextUtils.isEmpty(bean.salary_hour_str2)?View.GONE:View.VISIBLE}" />

                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="@{bean.salary_hour_str1}"
                                android:textColor="@color/colorPrimary"
                                android:textSize="@dimen/textSize15"
                                android:visibility="@{TextUtils.isEmpty(bean.salary_hour_str2)?View.GONE:View.VISIBLE}" />
                        </LinearLayout>

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="5dp"
                            android:layout_marginRight="@dimen/margin"
                            android:text="( 工厂同工同酬发工资,不足部分由工立方补贴 ) "
                            android:textColor="@color/commonText6" />

                    </LinearLayout>
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:visibility="@{bean.salary_type!=1?View.VISIBLE:View.GONE}">

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/margin"
                        android:paddingLeft="@dimen/margin">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="正  式  工:"
                            android:textColor="@color/commonText6"
                            android:textSize="@dimen/textSize15" />

                        <LinearLayout
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:orientation="vertical"
                            android:paddingRight="@dimen/margin">

                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="@{bean.salary_zhengshi}"
                                android:textColor="@color/black"
                                android:textSize="@dimen/textSize15" />

                            <LinearLayout
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content">

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:text="月工资"
                                    android:textColor="@color/black"
                                    android:textSize="@dimen/textSize15"
                                    android:visibility="@{TextUtils.isEmpty(bean.salary_zhengshi_str1)?View.GONE:View.VISIBLE}" />

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:text="@{bean.salary_zhengshi_str1}"
                                    android:textColor="@color/colorPrimary"
                                    android:textSize="@dimen/textSize15"
                                    android:visibility="@{TextUtils.isEmpty(bean.salary_zhengshi_str1)?View.GONE:View.VISIBLE}" />
                            </LinearLayout>

                        </LinearLayout>

                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/margin"
                        android:paddingLeft="@dimen/margin"
                        android:visibility="@{TextUtils.isEmpty(bean.salary_jiaban)?View.GONE:View.VISIBLE}">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="基本底薪:"
                            android:textColor="@color/commonText6"
                            android:textSize="@dimen/textSize15" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@{bean.salary_jiaban}"
                            android:textColor="@color/black"
                            android:textSize="@dimen/textSize15" />

                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/margin"
                        android:paddingLeft="@dimen/margin"
                        android:visibility="@{TextUtils.isEmpty(bean.salary_jiben_str)?View.GONE:View.VISIBLE}">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="底薪描述:"
                            android:textColor="@color/commonText6"
                            android:textSize="@dimen/textSize15" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@{bean.salary_jiben_str}"
                            android:textColor="@color/black"
                            android:textSize="@dimen/textSize15" />

                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/margin"
                        android:paddingLeft="@dimen/margin"
                        android:visibility="@{TextUtils.isEmpty(bean.salary_jiaban)?View.GONE:View.VISIBLE}">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="加  班  费:"
                            android:textColor="@color/commonText6"
                            android:textSize="@dimen/textSize15" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@{bean.salary_jiaban}"
                            android:textColor="@color/black"
                            android:textSize="@dimen/textSize15" />

                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/margin"
                        android:paddingLeft="@dimen/margin"
                        android:visibility="@{TextUtils.isEmpty(bean.salary_quanqin)?View.GONE:View.VISIBLE}">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="全   勤  奖:"
                            android:textColor="@color/commonText6"
                            android:textSize="@dimen/textSize15" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@{bean.salary_quanqin}"
                            android:textColor="@color/black"
                            android:textSize="@dimen/textSize15" />

                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/margin"
                        android:paddingLeft="@dimen/margin"
                        android:visibility="@{TextUtils.isEmpty(bean.salary_yeban)?View.GONE:View.VISIBLE}">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="夜班津贴:"
                            android:textColor="@color/commonText6"
                            android:textSize="@dimen/textSize15" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@{bean.salary_yeban}"
                            android:textColor="@color/black"
                            android:textSize="@dimen/textSize15" />

                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/margin"
                        android:paddingLeft="@dimen/margin"
                        android:visibility="@{TextUtils.isEmpty(bean.salary_jishu)?View.GONE:View.VISIBLE}">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="技术津贴:"
                            android:textColor="@color/commonText6"
                            android:textSize="@dimen/textSize15" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@{bean.salary_jishu}"
                            android:textColor="@color/black"
                            android:textSize="@dimen/textSize15" />

                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/margin"
                        android:paddingLeft="@dimen/margin"
                        android:visibility="@{TextUtils.isEmpty(bean.salary_jixiao)?View.GONE:View.VISIBLE}">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="绩效津贴:"
                            android:textColor="@color/commonText6"
                            android:textSize="@dimen/textSize15" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@{bean.salary_jixiao}"
                            android:textColor="@color/black"
                            android:textSize="@dimen/textSize15" />

                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/margin"
                        android:paddingLeft="@dimen/margin"
                        android:visibility="@{TextUtils.isEmpty(bean.salary_zhuanzheng)?View.GONE:View.VISIBLE}">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="其它津贴:"
                            android:textColor="@color/commonText6"
                            android:textSize="@dimen/textSize15" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@{bean.salary_zhuanzheng}"
                            android:textColor="@color/black"
                            android:textSize="@dimen/textSize15" />

                    </LinearLayout>
                </LinearLayout>

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/margin"
                    android:paddingLeft="@dimen/margin"
                    android:visibility="@{TextUtils.isEmpty(bean.salary_grant)?View.GONE:View.VISIBLE}">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="发放时间:"
                        android:textColor="@color/commonText6"
                        android:textSize="@dimen/textSize15" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@{bean.salary_grant}"
                        android:textColor="@color/black"
                        android:textSize="@dimen/textSize15" />

                </LinearLayout>

                <LinearLayout
                    android:id="@+id/ll_job_content"
                    android:layout_width="match_parent"
                    android:layout_height="44dp"
                    android:layout_marginTop="20dp"
                    android:background="@color/colorPageBg"
                    android:gravity="center">

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@mipmap/ic_left_line" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/margin"
                        android:layout_marginRight="@dimen/margin"
                        android:drawableLeft="@mipmap/ic_job_introduce"
                        android:drawablePadding="10dp"
                        android:text="岗位介绍"
                        android:textColor="@color/commonText9"
                        android:textSize="@dimen/textSize13" />

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@mipmap/ic_right_line" />

                </LinearLayout>

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="45dp"
                    android:drawableLeft="@mipmap/ic_one"
                    android:drawablePadding="@dimen/margin"
                    android:gravity="center_vertical"
                    android:paddingLeft="@dimen/margin"
                    android:text="招聘入职条件"
                    android:textColor="@color/color010101" />

                <View style="@style/CommonLine" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:lineSpacingExtra="@dimen/margin"
                    android:padding="@dimen/margin"
                    android:text="@{bean.employ_require}"
                    android:textColor="@color/commonText6"
                    android:textSize="@dimen/textSize15" />

                <View
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/margin"
                    android:background="@color/colorPageBg" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="45dp"
                    android:drawableLeft="@mipmap/ic_one"
                    android:drawablePadding="@dimen/margin"
                    android:gravity="center_vertical"
                    android:paddingLeft="@dimen/margin"
                    android:text="上班情况?"
                    android:textColor="@color/color010101"
                    android:textSize="@dimen/textSize16" />

                <View style="@style/CommonLine" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:visibility="@{TextUtils.isEmpty(bean.work_content)?View.GONE:View.VISIBLE}">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="20dp"
                        android:paddingLeft="@dimen/margin"
                        android:text="工作内容"
                        android:textColor="@color/blue"
                        android:textSize="@dimen/textSize15" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="10dp"
                        android:lineSpacingExtra="10dp"
                        android:paddingLeft="@dimen/margin"
                        android:paddingRight="@dimen/margin"
                        android:text="@{bean.work_content}"
                        android:textColor="@color/commonText6"
                        android:textSize="@dimen/textSize15" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:visibility="@{TextUtils.isEmpty(bean.work_time)?View.GONE:View.VISIBLE}">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="20dp"
                        android:paddingLeft="@dimen/margin"
                        android:text="工作时间"
                        android:textColor="@color/blue"
                        android:textSize="@dimen/textSize15" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="10dp"
                        android:lineSpacingExtra="10dp"
                        android:paddingLeft="@dimen/margin"
                        android:paddingRight="@dimen/margin"
                        android:text="@{bean.work_time}"
                        android:textColor="@color/commonText6"
                        android:textSize="@dimen/textSize15" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:visibility="@{TextUtils.isEmpty(bean.work_mode)?View.GONE:View.VISIBLE}">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="20dp"
                        android:paddingLeft="@dimen/margin"
                        android:text="工作方式"
                        android:textColor="@color/blue"
                        android:textSize="@dimen/textSize15" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="10dp"
                        android:layout_marginBottom="20dp"
                        android:lineSpacingExtra="10dp"
                        android:paddingLeft="@dimen/margin"
                        android:paddingRight="@dimen/margin"
                        android:text="@{bean.work_mode}"
                        android:textColor="@color/commonText6"
                        android:textSize="@dimen/textSize15" />
                </LinearLayout>

                <View
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/margin"
                    android:background="@color/colorPageBg" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="45dp"
                    android:drawableLeft="@mipmap/ic_one"
                    android:drawablePadding="@dimen/margin"
                    android:gravity="center_vertical"
                    android:paddingLeft="@dimen/margin"
                    android:text="吃住咋样?"
                    android:textColor="@color/color010101"
                    android:textSize="@dimen/textSize16" />

                <View style="@style/CommonLine" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:visibility="@{TextUtils.isEmpty(bean.food_situation)?View.GONE:View.VISIBLE}">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="20dp"
                        android:paddingLeft="@dimen/margin"
                        android:text="伙食情况"
                        android:textColor="@color/blue"
                        android:textSize="@dimen/textSize15" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="10dp"
                        android:lineSpacingExtra="10dp"
                        android:paddingLeft="@dimen/margin"
                        android:paddingRight="@dimen/margin"
                        android:text="@{bean.food_situation}"
                        android:textColor="@color/commonText6"
                        android:textSize="@dimen/textSize15" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:visibility="@{TextUtils.isEmpty(bean.residence_situation)?View.GONE:View.VISIBLE}">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="20dp"
                        android:paddingLeft="@dimen/margin"
                        android:text="住宿情况"
                        android:textColor="@color/blue"
                        android:textSize="@dimen/textSize15" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="10dp"
                        android:lineSpacingExtra="10dp"
                        android:paddingLeft="@dimen/margin"
                        android:paddingRight="@dimen/margin"
                        android:text="@{bean.residence_situation}"
                        android:textColor="@color/commonText6"
                        android:textSize="@dimen/textSize15" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:visibility="@{TextUtils.isEmpty(bean.environment)?View.GONE:View.VISIBLE}">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="20dp"
                        android:paddingLeft="@dimen/margin"
                        android:text="工作环境"
                        android:textColor="@color/blue"
                        android:textSize="@dimen/textSize15" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="10dp"
                        android:layout_marginBottom="20dp"
                        android:lineSpacingExtra="10dp"
                        android:paddingLeft="@dimen/margin"
                        android:paddingRight="@dimen/margin"
                        android:text="@{bean.environment}"
                        android:textColor="@color/commonText6"
                        android:textSize="@dimen/textSize15" />
                </LinearLayout>

                <View
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/margin"
                    android:background="@color/colorPageBg" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="45dp"
                    android:drawableLeft="@mipmap/ic_one"
                    android:drawablePadding="@dimen/margin"
                    android:gravity="center_vertical"
                    android:paddingLeft="@dimen/margin"
                    android:text="有啥福利?"
                    android:textColor="@color/color010101"
                    android:textSize="@dimen/textSize16" />

                <View style="@style/CommonLine" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:visibility="@{TextUtils.isEmpty(bean.benefits)?View.GONE:View.VISIBLE}">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="20dp"
                        android:paddingLeft="@dimen/margin"
                        android:text="福利待遇"
                        android:textColor="@color/blue"
                        android:textSize="@dimen/textSize15" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="10dp"
                        android:lineSpacingExtra="10dp"
                        android:paddingLeft="@dimen/margin"
                        android:paddingRight="@dimen/margin"
                        android:text="@{bean.benefits}"
                        android:textColor="@color/commonText6"
                        android:textSize="@dimen/textSize15" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:visibility="@{TextUtils.isEmpty(bean.social_security)?View.GONE:View.VISIBLE}">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="20dp"
                        android:paddingLeft="@dimen/margin"
                        android:text="社会保险"
                        android:textColor="@color/blue"
                        android:textSize="@dimen/textSize15" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="10dp"
                        android:lineSpacingExtra="10dp"
                        android:paddingLeft="@dimen/margin"
                        android:paddingRight="@dimen/margin"
                        android:text="@{bean.social_security}"
                        android:textColor="@color/commonText6"
                        android:textSize="@dimen/textSize15" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:visibility="@{TextUtils.isEmpty(bean.holidays)?View.GONE:View.VISIBLE}">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="20dp"
                        android:paddingLeft="@dimen/margin"
                        android:text="休息节日"
                        android:textColor="@color/blue"
                        android:textSize="@dimen/textSize15" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="10dp"
                        android:layout_marginBottom="20dp"
                        android:lineSpacingExtra="10dp"
                        android:paddingLeft="@dimen/margin"
                        android:paddingRight="@dimen/margin"
                        android:textColor="@color/commonText6"
                        android:textSize="@dimen/textSize15" />
                </LinearLayout>

                <View
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/margin"
                    android:background="@color/colorPageBg" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="45dp"
                    android:drawableLeft="@mipmap/ic_one"
                    android:drawablePadding="@dimen/margin"
                    android:gravity="center_vertical"
                    android:paddingLeft="@dimen/margin"
                    android:text="温馨提示"
                    android:textColor="@color/color010101" />

                <View style="@style/CommonLine" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="20dp"
                    android:layout_marginBottom="20dp"
                    android:lineSpacingExtra="10dp"
                    android:paddingLeft="@dimen/margin"
                    android:paddingRight="@dimen/margin"
                    android:text="@{bean.reminder}"
                    android:textColor="@color/commonText6"
                    android:textSize="@dimen/textSize15" />

                <LinearLayout
                    android:id="@+id/ll_enterprise_content"
                    android:layout_width="match_parent"
                    android:layout_height="44dp"
                    android:background="@color/colorPageBg"
                    android:gravity="center">

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@mipmap/ic_left_line" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/margin"
                        android:layout_marginRight="@dimen/margin"
                        android:drawableLeft="@mipmap/ic_enterprise_detail"
                        android:drawablePadding="10dp"
                        android:text="企业详情"
                        android:textColor="@color/commonText9"
                        android:textSize="@dimen/textSize13" />

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@mipmap/ic_right_line" />

                </LinearLayout>

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="45dp"
                    android:drawableLeft="@mipmap/ic_one"
                    android:drawablePadding="@dimen/margin"
                    android:gravity="center_vertical"
                    android:paddingLeft="@dimen/margin"
                    android:text="工厂简介"
                    android:textColor="@color/color010101" />

                <View style="@style/CommonLine" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="20dp"
                    android:layout_marginBottom="20dp"
                    android:lineSpacingExtra="10dp"
                    android:paddingLeft="@dimen/margin"
                    android:paddingRight="@dimen/margin"
                    android:text="@{bean.profile}"
                    android:textColor="@color/commonText6"
                    android:textSize="@dimen/textSize15" />

                <View
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/margin"
                    android:background="@color/colorPageBg" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="45dp"
                    android:gravity="center_vertical"
                    android:paddingLeft="@dimen/margin"
                    android:paddingRight="@dimen/margin">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:drawableLeft="@mipmap/ic_one"
                        android:drawablePadding="@dimen/margin"
                        android:gravity="center_vertical"
                        android:text="工厂在哪?"
                        android:textColor="@color/color010101"
                        android:textSize="@dimen/textSize16" />

                    <TextView
                        android:id="@+id/tv_look_map"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="查看地图"
                        android:textColor="@color/blue"
                        android:textSize="@dimen/textSize16" />

                </LinearLayout>

                <View style="@style/CommonLine" />

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="164dp"
                    android:layout_marginTop="@dimen/margin"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/iv_map"
                        android:layout_width="match_parent"
                        android:layout_height="155dp"
                        android:scaleType="centerCrop" />

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_centerHorizontal="true"
                        android:src="@mipmap/ic_map_company" />
                </RelativeLayout>

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/margin"
                    android:paddingLeft="@dimen/margin">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="企业地址:"
                        android:textColor="@color/commonText6"
                        android:textSize="@dimen/textSize15" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@{bean.address}"
                        android:textColor="@color/black"
                        android:textSize="@dimen/textSize15" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/margin"
                    android:paddingLeft="@dimen/margin">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="乘车路线:"
                        android:textColor="@color/commonText6"
                        android:textSize="@dimen/textSize15" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@{bean.bus_line}"
                        android:textColor="@color/black"
                        android:textSize="@dimen/textSize15" />

                </LinearLayout>

                <LinearLayout
                    android:id="@+id/ll_teacher_loc"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/margin"
                    android:layout_marginBottom="20dp"
                    android:paddingLeft="@dimen/margin">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="驻厂老师接站位置:"
                        android:textColor="@color/commonText6"
                        android:textSize="@dimen/textSize15" />

                    <LinearLayout
                        android:id="@+id/ll_loc"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:orientation="vertical" />

                </LinearLayout>

                <LinearLayout
                    android:id="@+id/ll_recommended_content"
                    android:layout_width="match_parent"
                    android:layout_height="44dp"
                    android:background="@color/colorPageBg"
                    android:gravity="center">

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@mipmap/ic_left_line" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/margin"
                        android:layout_marginRight="@dimen/margin"
                        android:drawableLeft="@mipmap/ic_recommended"
                        android:drawablePadding="10dp"
                        android:text="为您推荐"
                        android:textColor="@color/commonText9"
                        android:textSize="@dimen/textSize13" />

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@mipmap/ic_right_line" />

                </LinearLayout>

                <com.example.xrecyclerview.XRecyclerView
                    android:id="@+id/xrv_recyclerView"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginBottom="60dp"
                    android:background="@color/white"
                    android:scrollbarFadeDuration="1"
                    android:scrollbarSize="1dp"
                    android:scrollbarThumbVertical="@color/commonText6"
                    android:scrollbars="vertical" />

            </LinearLayout>

        </com.program.ccmei.view.SuspensionTopScrollView>

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

            <View
                android:id="@+id/view_top"
                android:layout_width="match_parent"
                android:layout_height="0dp" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/tb_factory"
                android:layout_width="match_parent"
                android:layout_height="45dp"
                android:background="@color/colorAccent"

                app:contentInsetStart="0.0dp"
                app:layout_scrollFlags="enterAlways|scroll"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:theme="@style/ToolbarStyle">

                <TextView
                    android:id="@+id/tv_title_factory"
                    android:layout_width="200dp"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:ellipsize="end"
                    android:lines="1"
                    android:text=""
                    android:textColor="@color/white"
                    android:textSize="@dimen/textSize18"
                    android:textStyle="bold" />

                <ImageView
                    android:id="@+id/iv_factory_share"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="right"
                    android:layout_marginRight="@dimen/margin"
                    android:layout_toLeftOf="@+id/iv_factory_share"
                    android:src="@mipmap/share_icon" />

                <ImageView
                    android:id="@+id/iv_factory_collection"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="right"
                    android:layout_marginRight="@dimen/margin"
                    android:src="@mipmap/collection_icon" />

            </android.support.v7.widget.Toolbar>

            <LinearLayout
                android:id="@+id/ll_tb"
                android:layout_width="match_parent"
                android:layout_height="35dp"
                android:background="@color/white">

                <LinearLayout
                    android:id="@+id/ll_salary"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center_horizontal"
                    android:orientation="vertical">

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:gravity="center">

                        <ImageView
                            android:id="@+id/iv_salary"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:src="@mipmap/ic_loc_red" />

                        <TextView
                            android:id="@+id/tv_salary"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:text="薪资"
                            android:textColor="@color/black" />

                    </LinearLayout>

                    <View
                        android:id="@+id/view_salary"
                        android:layout_width="75dp"
                        android:layout_height="1dp"
                        android:background="@color/colorPrimary" />

                </LinearLayout>

                <LinearLayout
                    android:id="@+id/ll_jobs"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:orientation="vertical">

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:gravity="center">

                        <ImageView
                            android:id="@+id/iv_jobs"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:src="@mipmap/ic_loc_red" />

                        <TextView
                            android:id="@+id/tv_jobs"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:text="岗位"
                            android:textColor="@color/black" />

                    </LinearLayout>

                    <View
                        android:id="@+id/view_jobs"
                        android:layout_width="75dp"
                        android:layout_height="2dp"
                        android:background="@color/colorPrimary" />

                </LinearLayout>

                <LinearLayout
                    android:id="@+id/ll_enterprise"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:orientation="vertical">

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:gravity="center">

                        <ImageView
                            android:id="@+id/iv_enterprise"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:src="@mipmap/ic_loc_red" />

                        <TextView
                            android:id="@+id/tv_enterprise"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:text="企业"
                            android:textColor="@color/black" />

                    </LinearLayout>

                    <View
                        android:id="@+id/view_enterprise"
                        android:layout_width="75dp"
                        android:layout_height="2dp"
                        android:background="@color/colorPrimary" />

                </LinearLayout>

                <LinearLayout
                    android:id="@+id/ll_recommended"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:orientation="vertical">

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:gravity="center">

                        <ImageView
                            android:id="@+id/iv_recommended"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:src="@mipmap/ic_loc_red" />

                        <TextView
                            android:id="@+id/tv_recommended"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:text="推荐"
                            android:textColor="@color/black" />

                    </LinearLayout>

                    <View
                        android:id="@+id/view_recommended"
                        android:layout_width="75dp"
                        android:layout_height="2dp"
                        android:background="@color/colorPrimary" />

                </LinearLayout>

            </LinearLayout>

        </LinearLayout>

        <LinearLayout
            android:id="@+id/ll_sign_up"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_alignParentBottom="true"
            android:background="@color/white"
            android:orientation="vertical">

            <View style="@style/CommonLine" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="center_vertical">

                <TextView
                    android:id="@+id/tv_questions_answers"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="0.5"
                    android:drawableTop="@mipmap/ic_answer"
                    android:gravity="center"
                    android:text="问答"
                    android:textColor="@color/commonText6"
                    android:textSize="@dimen/textSize12"
                    android:visibility="gone" />

                <TextView
                    android:id="@+id/tv_sign_up"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="@color/colorPrimary"
                    android:gravity="center"
                    android:text="我要报名"
                    android:textColor="@color/white"
                    android:textSize="@dimen/textSize18" />

            </LinearLayout>

        </LinearLayout>

    </RelativeLayout>
</layout>

自定义SrollView

/**
 * Created by Administrator on 2017/6/7.
 * <p>
 * 悬浮 顶部的 scrollView
 */
public class SuspensionTopScrollView extends ScrollView {
    private OnScrollListener onScrollListener;
    boolean isAnimRun = false;

    public SuspensionTopScrollView(Context context) {
        this(context, null);
    }

    public SuspensionTopScrollView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public SuspensionTopScrollView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    /**
     * 设置滚动接口
     *
     * @param onScrollListener
     */
    public void setOnScrollListener(OnScrollListener onScrollListener) {
        this.onScrollListener = onScrollListener;
    }


    @Override
    public int computeVerticalScrollRange() {
        return super.computeVerticalScrollRange();
    }


    @Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
        super.onScrollChanged(l, t, oldl, oldt);
        if (onScrollListener != null) {
            onScrollListener.onScroll(t);
        }
    }

    public void smoothScrollTo(final int dis) {
//        if (isAnimRun) {
//            return;
//        }

        @SuppressLint("ObjectAnimatorBinding")
        ObjectAnimator anim = ObjectAnimator.ofFloat(this, "ypx", 0.0f, 1.0f);
        anim.setDuration(100);
        anim.setInterpolator(new AccelerateDecelerateInterpolator());
        anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                isAnimRun = true;
                int mdis = (int) ((dis - getScrollY()) * (Float) animation.getAnimatedValue());
                scrollBy(0, mdis);



            }
        });
        anim.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animator) {

            }

            @Override
            public void onAnimationEnd(Animator animator) {
                isAnimRun = false;
            }

            @Override
            public void onAnimationCancel(Animator animator) {

            }

            @Override
            public void onAnimationRepeat(Animator animator) {

            }
        });
        anim.start();
    }


    /**
     * 滚动的回调接口
     *
     * @author xiaanming
     */
    public interface OnScrollListener {
        /**
         * 回调方法, 返回MyScrollView滑动的Y方向距离
         *
         * @param scrollY 、
         */
        public void onScroll(int scrollY);
    }
}

代码

 /**
     * 初始化头部悬停的 效果
     */
    private void initTopSuspension() {
        bindingView.scrollView.setOnScrollListener(this);
        bindingView.rlContent.getViewTreeObserver()
                .addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
                    @Override
                    public void onGlobalLayout() {
                        onScroll(bindingView.scrollView.getScrollY());
                    }
                });
    }
 @Override
    public void onScroll(int scrollY) {
//        setTopVisibleOrGone(scrollY);
        int top1 = bindingView.llSalaryContent.getTop() - bindingView.llTb.getHeight()
                - bindingView.tbFactory.getHeight()
                - bindingView.viewTop.getHeight();
        int top2 = bindingView.llJobContent.getTop() - bindingView.llTb.getHeight()
                - bindingView.tbFactory.getHeight()
                - bindingView.viewTop.getHeight();
        int top3 = bindingView.llEnterpriseContent.getTop() - bindingView.llTb.getHeight()
                - bindingView.tbFactory.getHeight()
                - bindingView.viewTop.getHeight();
        int top4 = bindingView.llRecommendedContent.getTop() - bindingView.llTb.getHeight()
                - bindingView.tbFactory.getHeight()
                - bindingView.viewTop.getHeight();
        if (scrollY > (top1 - 10)) {
            bindingView.llTb.setVisibility(View.VISIBLE);
        } else {
            bindingView.llTb.setVisibility(View.GONE);
        }

        if (scrollY >= top1 && scrollY < top2) {
            bindingView.llTb.setVisibility(View.VISIBLE);
            initSelectTextView(bindingView.tvSalary, bindingView.viewSalary, bindingView.ivSalary);
        } else if (scrollY >= top2 && scrollY < top3) {
            bindingView.llTb.setVisibility(View.VISIBLE);
            initSelectTextView(bindingView.tvJobs, bindingView.viewJobs, bindingView.ivJobs);
        } else if (scrollY >= top3 && scrollY < top4) {
            bindingView.llTb.setVisibility(View.VISIBLE);
            initSelectTextView(bindingView.tvEnterprise, bindingView.viewEnterprise, bindingView.ivEnterprise);
        } else if (scrollY >= top4) {
            bindingView.llTb.setVisibility(View.VISIBLE);
            initSelectTextView(bindingView.tvRecommended, bindingView.viewRecommended, bindingView.ivRecommended);
        }
    }
 private void initSelectTextView(TextView tv, View view, ImageView iv) {
        if (tv == null) {
            return;
        }
        initFixationTextView();
        tv.setTextColor(getResources().getColor(R.color.colorPrimary));
        view.setVisibility(View.VISIBLE);
        iv.setVisibility(View.VISIBLE);
    }
  private void initFixationTextView() {
        bindingView.tvSalary.setTextColor(getResources().getColor(R.color.black));
        bindingView.tvJobs.setTextColor(getResources().getColor(R.color.black));
        bindingView.tvEnterprise.setTextColor(getResources().getColor(R.color.black));
        bindingView.tvRecommended.setTextColor(getResources().getColor(R.color.black));
        bindingView.viewSalary.setVisibility(View.INVISIBLE);
        bindingView.viewJobs.setVisibility(View.INVISIBLE);
        bindingView.viewEnterprise.setVisibility(View.INVISIBLE);
        bindingView.viewRecommended.setVisibility(View.INVISIBLE);
        bindingView.ivSalary.setVisibility(View.INVISIBLE);
        bindingView.ivJobs.setVisibility(View.INVISIBLE);
        bindingView.ivEnterprise.setVisibility(View.INVISIBLE);
        bindingView.ivRecommended.setVisibility(View.INVISIBLE);
    }

直接看代码吧 不想说话

猜你喜欢

转载自blog.csdn.net/lijinweii/article/details/102736985